w如何通过一个mysql方法,而不是借助脚本判断?INET6_ATON(
expr
)
https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_inet-aton
https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_inet6-aton
Given an IPv6 or IPv4 network address as a string, returns a binary string that represents the numeric value of the address in network byte order (big endian). Because numeric-format IPv6 addresses require more bytes than the largest integer type, the representation returned by this function has the VARBINARY
data type: VARBINARY(16)
for IPv6 addresses and VARBINARY(4)
for IPv4 addresses. If the argument is not a valid address, INET6_ATON()
returns NULL
.
The following examples use HEX()
to display the INET6_ATON()
result in printable form: