IPV6_STRING_TO_NUM
IPV6_STRING_TO_NUMâ
IPV6_STRING_TO_NUM
Descriptionâ
Syntaxâ
VARCHAR IPV6_STRING_TO_NUM(VARCHAR ipv6_string)
The reverse function of IPv6NumToString, it takes an IP address String and returns an IPv6 address in binary format. If the input string contains a valid IPv4 address, returns its IPv6 equivalent.
Noticeâ
Will return an error if the input string is not a valid IP address or NULL
Exampleâ
mysql> select hex(ipv6_string_to_num('1111::ffff'));
+---------------------------------------+
| hex(ipv6_string_to_num('1111::ffff')) |
+---------------------------------------+
| 1111000000000000000000000000FFFF |
+---------------------------------------+
1 row in set (0.02 sec)
mysql> select hex(ipv6_string_to_num('192.168.0.1'));
+----------------------------------------+
| hex(ipv6_string_to_num('192.168.0.1')) |
+----------------------------------------+
| 00000000000000000000FFFFC0A80001 |
+----------------------------------------+
1 row in set (0.02 sec)
mysql> select hex(ipv6_string_to_num('notaaddress'));
ERROR 1105 (HY000): errCode = 2, detailMessage = (172.17.0.2)[CANCELLED][E33] Invalid IPv6 value
mysql> select addr_src, hex(ipv6_string_to_num(addr_src)) from ipv4_string_test where addr_src is null;
ERROR 1105 (HY000): errCode = 2, detailMessage = (172.17.0.2)[CANCELLED][E33] Null Input, you may consider convert it to a valid default IPv6 value like '::' first
Keywordsâ
IPV6_STRING_TO_NUM, IP