INET_ATON

SinceVersion dev

inet_aton

description

Syntax

BIGINT INET_ATON(VARCHAR ipv4_string)

获取包含 IPv4 地址的字符串,格式为 A.B.C.D(点分隔的十进制数字)。返回一个 BIGINT 数字,表示相应的大端 IPv4 地址。

notice

该函数为ipv4_string_to_num_or_null的别称。如果输入字符串不是有效的 IPv4 地址或者NULL,将返回NULL,和MySQL一样

example

1. mysql> select inet_aton('192.168.0.1');
2. +-------------------------------------------+
3. | ipv4_string_to_num_or_null('192.168.0.1') |
4. +-------------------------------------------+
5. | 3232235521                                |
6. +-------------------------------------------+
7. 1 row in set (0.01 sec)

9. mysql> SELECT inet_aton('192.168');
10. +---------------------------------------+
11. | ipv4_string_to_num_or_null('192.168') |
12. +---------------------------------------+
13. | NULL                                  |
14. +---------------------------------------+
15. 1 row in set (0.01 sec)

keywords

INET_ATON, IP