IS_IPV4 | Syntax: | IS_IPV4(String) | Return value: | INTEGER | Function type: | Miscellaneous function | |
|
|
The IS_IPV4() function returns 1 if the "String" argument contains a valid IPv4 address.
If the value is not a valid IPv4 address or is NULL, the IS_IPV4() function returns 0.
IS_IPV4() is more strict than INET_ATON() and just as strict as the INET6_ATON() function. |
SQL Examples for the IS_IPV4 function |
|
SELECT IS_IPV4('127.0.0.1');
SELECT IS_IPV4('66.249.66.4');
SELECT IS_IPV4('257.0.0.1');
SELECT IS_IPV4('');
SELECT IS_IPV4(null);
|
|
IS_IPV4('127.0.0.1') |
int(1) |
1 |
|
|
IS_IPV4('66.249.66.4') |
int(1) |
1 |
|
|
IS_IPV4('257.0.0.1') |
int(1) |
0 |
|
|
|
|
|
The examples were created with the MyWAY SQL manager: |
How to use the IS_IPV4() function in MySQL and MariaDB databases |
In MySQL and MariaDB the IS_IPV4() function is used to determine whether a specific string represents a valid IPv4 address. The function takes a string as an argument and returns 1 if the string contains a valid IPv4 address, otherwise 0. The function performs a basic syntax check on the input string to determine if the argument follows the IPv4 format. It does not perform network-level validation and does not check if the IP address is reachable or assigned.
For example, the feature can validate user-provided IP addresses to ensure they conform to IPv4 format before further processing or storage. In queries, for example, the function can be used to filter and retrieve only rows that contain valid IPv4 addresses in a table column. Applying IS_IPV4() as a constraint or validation rule can ensure that only valid IPv4 addresses are inserted or updated in a table. |
|
Further MySQL und MariaDB SQL Miscellaneous functions |
|