当前位置:网站首页>IP storage and query in MySQL
IP storage and query in MySQL
2022-07-06 00:58:00 【Diligently_】
MySQL Two methods are provided to handle this ip Address
- inet_aton hold ip Convert to unsigned integer (4-8 position )
- inet_ntoa The integer ip To address
- Before inserting data , First use inet_aton hold ip Address to integer , You can save space , When displaying data , Use inet_ntoa The integer ip Address to address display
select INET_ATON('192.168.0.1'); select INET_NTOA('3232235521');
select
INET_ATON('192.168.0.1')
select
INET_NTOA('3232235521')
Create table statement :
CREATE TABLE `test_ip` (
`id` bigint NOT NULL AUTO_INCREMENT,
`ipstr` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'str Type of ip',
`ip_aton` bigint DEFAULT NULL COMMENT ' After converting to unsigned ip data ',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Insert statement sql:
INSERT INTO test_ip (ipstr,ip_aton) VALUES ('192.168.0.1',INET_ATON('192.168.0.1'));
The result after inserting is shown in the figure :
The query above sql:
SELECT id,ipstr,ip_aton,INET_NTOA(ip_aton) from test_ip
边栏推荐
- Pbootcms plug-in automatically collects fake original free plug-ins
- 新手入门深度学习 | 3-6:优化器optimizers
- cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】
- 图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
- Dynamic programming -- linear DP
- [groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)
- Cglib dynamic agent -- example / principle
- Zhuhai laboratory ventilation system construction and installation instructions
- Convert binary search tree into cumulative tree (reverse middle order traversal)
- Introduction of motor
猜你喜欢
JVM_ 15_ Concepts related to garbage collection
测试/开发程序员的成长路线,全局思考问题的问题......
2020.2.13
Keepalive component cache does not take effect
Spark AQE
Cf:c. the third problem
[groovy] compile time meta programming (AST syntax tree conversion with annotations | define annotations and use groovyasttransformationclass to indicate ast conversion interface | ast conversion inte
Illustrated network: the principle behind TCP three-time handshake, why can't two-time handshake?
The relationship between FPGA internal hardware structure and code
[groovy] XML serialization (use markupbuilder to generate XML data | create sub tags under tag closures | use markupbuilderhelper to add XML comments)
随机推荐
cf:C. The Third Problem【关于排列这件事】
Finding the nearest common ancestor of binary tree by recursion
esxi的安装和使用
Recoverable fuse characteristic test
Curlpost PHP
Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks
devkit入门
WordPress collection plug-in automatically collects fake original free plug-ins
Model analysis of establishment time and holding time
[groovy] JSON serialization (convert class objects to JSON strings | convert using jsonbuilder | convert using jsonoutput | format JSON strings for output)
cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】
Cf:c. the third problem
Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
Building core knowledge points
I'm interested in watching Tiktok live beyond concert
Hundreds of lines of code to implement a JSON parser
KDD 2022 | 脑电AI助力癫痫疾病诊断
Daily practice - February 13, 2022
ubantu 查看cudnn和cuda的版本
Spark AQE