IPV4_NUM_TO_STRING

SinceVersion dev

IPV4_NUM_TO_STRING

description

Syntax

VARCHAR IPV4_NUM_TO_STRING(BIGINT ipv4_num)

接受一个类型为Int16、Int32、Int64 且大端表示的 IPv4 的地址,返回相应 IPv4 的字符串表现形式,格式为A.B.C.D(以点分割的十进制数字)。

notice

对于负数或超过4294967295 (即 '255.255.255.255')的入参都返回NULL,表示无效收入

example

  1. mysql> select ipv4_num_to_string(3232235521);
  2. +--------------------------------+
  3. | ipv4_num_to_string(3232235521) |
  4. +--------------------------------+
  5. | 192.168.0.1 |
  6. +--------------------------------+
  7. 1 row in set (0.01 sec)
  8. mysql> select num,ipv4_num_to_string(num) from ipv4_bi;
  9. +------------+---------------------------+
  10. | num | ipv4_num_to_string(`num`) |
  11. +------------+---------------------------+
  12. | -1 | NULL |
  13. | 0 | 0.0.0.0 |
  14. | 2130706433 | 127.0.0.1 |
  15. | 4294967295 | 255.255.255.255 |
  16. | 4294967296 | NULL |
  17. +------------+---------------------------+
  18. 7 rows in set (0.01 sec)

keywords

IPV4_NUM_TO_STRING, IP