当前位置:网站首页>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
边栏推荐
- Gartner released the prediction of eight major network security trends from 2022 to 2023. Zero trust is the starting point and regulations cover a wider range
- The inconsistency between the versions of dynamic library and static library will lead to bugs
- 95后CV工程师晒出工资单,狠补了这个,真香...
- Folding and sinking sand -- weekly record of ETF
- Idea remotely submits spark tasks to the yarn cluster
- STM32 key chattering elimination - entry state machine thinking
- MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
- esxi的安装和使用
- MIT博士论文 | 使用神经符号学习的鲁棒可靠智能系统
- Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
猜你喜欢
Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
毕设-基于SSM高校学生社团管理系统
WordPress collection plug-in automatically collects fake original free plug-ins
Xunrui CMS plug-in automatically collects fake original free plug-ins
cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)
Dede collection plug-in free collection release push plug-in
[groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)
Cf:h. maximum and [bit operation practice + K operations + maximum and]
What is the most suitable book for programmers to engage in open source?
随机推荐
Hundreds of lines of code to implement a JSON parser
Spark DF adds a column
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
The value of applet containers
Zhuhai's waste gas treatment scheme was exposed
孤勇者
China Taiwan strategy - Chapter 8: digital marketing assisted by China Taiwan
After Luke zettlemoyer, head of meta AI Seattle research | trillion parameters, will the large model continue to grow?
Illustrated network: the principle behind TCP three-time handshake, why can't two-time handshake?
How spark gets columns in dataframe --column, $, column, apply
Ubantu check cudnn and CUDA versions
curlpost-php
Arduino hexapod robot
282. Stone consolidation (interval DP)
Dedecms plug-in free SEO plug-in summary
[groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)
esxi的安装和使用
The inconsistency between the versions of dynamic library and static library will lead to bugs
cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】
KDD 2022 | EEG AI helps diagnose epilepsy