ID EN
Miscellaneous Functions

IS_IPV4(expr)

MySQL 8.4

Returns 1 if the argument is a valid IPv4 address specified as a string, 0 otherwise. Returns NULL if expr is NULL.

Syntax

MYSQL
SELECT IS_IPV4('10.0.5.9'), IS_IPV4('10.0.5.256');
1, 0

Examples

Example

For a given argument, if IS_IPV4() returns 1, INET_ATON() (and INET6_ATON()) returns non-NULL. The converse statement is not true: In some cases, INET_ATON() returns non-NULL when IS_IPV4() returns 0.

MYSQL
SELECT IS_IPV4('10.0.5.9'), IS_IPV4('10.0.5.256');
1, 0