mysql - Convert ipv4 & ipv6 both into number -


inet_aton() 

return numeric value of ip address

inet6_aton() 

return numeric value of ipv6 address

i have column contain ipv4 & ipv6 both.

i try convert number 'ip_long'(column's name)

i use inet_aton, convert ipv4

my question is, inet6_aton convert ipv6 or both?

is function can convert both? have million rows in db need convert.

inet6_aton() convert both ipv4 , ipv6. know, need mysql version 5.6.x or higher.

the catch use inet6_aton() , inet6_ntoa(). column store the converted ips of varbinary(16) type.

select inet6_ntoa(inet6_aton("192.168.1.1"));  select inet6_ntoa(inet6_aton("2001:db8::1")); 

remember ip column test_table varbinary(16);


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -