IS_IPV6 | Syntax: | IS_IPV6(String) | Return value: | INTEGER | Function type: | Miscellaneous function | |
|
|
The IS_IPV6() function returns 1 if the IPv6 address specified in the "String" expression is valid.
If the IPv6 address is invalid or NULL, the function returns 0.
IPv4 addresses are assumed to be invalid in this function. |
SQL Examples for the IS_IPV6 function |
|
SELECT IS_IPV6('fe80::8ade:7cff:fef7:e3a5');
SELECT IS_IPV6('2a02:3030:81e:d48d:cd91:e972:5c6b:90a8');
SELECT IS_IPV6('::1');
SELECT IS_IPV6('127.0.0.1');
SELECT IS_IPV6('');
SELECT IS_IPV6(null);
|
|
IS_IPV6('fe80::8ade:7cff:fef7:e3a5') |
int(1) |
1 |
|
|
IS_IPV6('2a02:3030:81e:d48d:cd91:e972:5c6b:90a8') |
int(1) |
1 |
|
|
|
IS_IPV6('127.0.0.1') |
int(1) |
0 |
|
|
|
|
|
The examples were created with the MyWAY SQL manager: |
How to use the IS_IPV6() function in MySQL and MariaDB databases |
The IS_IPV6() function in MySQL and MariaDB can be used to determine whether a specific string represents a valid IPv6 address. The function takes a character string within the adress as an argument and returns 1 if the string contains a valid IPv6 address, otherwise 0. The function only performs a basic syntax check on the input string to determine if the argument follows the IPv6 format. It does not perform network-level validation and does not check if the IPv6 address is reachable or assigned.
For example, the feature can validate IP addresses to ensure they conform to IPv6 format before further processing or storage. In queries, for example, the function can be used to filter and retrieve only rows that contain valid IPv6 addresses from a table. Applying IS_IPV6() as a constraint or validation rule can ensure that only valid IPv6 addresses are inserted or updated in a table. |
|
Further MySQL und MariaDB SQL Miscellaneous functions |
|