Heim  >  Artikel  >  Datenbank  >  MySql Ip地址 储存

MySql Ip地址 储存

WBOY
WBOYOriginal
2016-06-07 16:27:11860Durchsuche

MySql Ip地址 存储 特殊字段-ipv4地址的存取 存取ip地址可以使用mysql中的两个函数将ipv4字符串转换成为整数,整数的存取比字符串快。两个特殊的函数是: Ip地址转成数字:select inet_aton("192.168.1.1"); 结果 +--------------------------+ | inet_aton("

MySql Ip地址 存储
特殊字段-ipv4地址的存取
存取ip地址可以使用mysql中的两个函数将ipv4字符串转换成为整数,整数的存取比字符串快。两个特殊的函数是:
Ip地址转成数字:select inet_aton("192.168.1.1");
结果
+--------------------------+
| inet_aton("192.168.1.1") |
+--------------------------+
|  3232235777 |
+--------------------------+
数字转换成为ip地址
select inet_ntoa(3232235778);
结果为:
+-----------------------+
| inet_ntoa(3232235778) |
+-----------------------+
| 192.168.1.2       |
+-----------------------+
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn