IPV6_STRING_TO_NUM_OR_NULL

IPV6_STRING_TO_NUM_OR_NULL

Description

Syntax

VARCHAR IPV6_STRING_TO_NUM_OR_NULL(VARCHAR ipv6_string)

VARCHAR INET6_ATON(VARCHAR ipv6_string)

IPv6NumToString 的反向函数,它接受一个 IP 地址字符串并返回二进制格式的 IPv6 地址。 如果输入字符串包含有效的 IPv4 地址,则返回其等效的 IPv6 地址。

Notice

如果输入非法的 IP 地址,会返回 NULL。该函数有一个别名为 INET6_ATON

Example

  1. mysql> select hex(ipv6_string_to_num_or_null('1111::ffff'));
  2. +-----------------------------------------------+
  3. | hex(ipv6_string_to_num_or_null('1111::ffff')) |
  4. +-----------------------------------------------+
  5. | 1111000000000000000000000000FFFF |
  6. +-----------------------------------------------+
  7. 1 row in set (0.01 sec)
  8. mysql> select hex(ipv6_string_to_num_or_null('192.168.0.1'));
  9. +------------------------------------------------+
  10. | hex(ipv6_string_to_num_or_null('192.168.0.1')) |
  11. +------------------------------------------------+
  12. | 00000000000000000000FFFFC0A80001 |
  13. +------------------------------------------------+
  14. 1 row in set (0.02 sec)
  15. mysql> select hex(ipv6_string_to_num_or_null('notaaddress'));
  16. +------------------------------------------------+
  17. | hex(ipv6_string_to_num_or_null('notaaddress')) |
  18. +------------------------------------------------+
  19. | NULL |
  20. +------------------------------------------------+
  21. 1 row in set (0.02 sec)

Keywords

IPV6_STRING_TO_NUM_OR_NULL, INET6_ATON, IP