当前位置:网站首页>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
边栏推荐
- synchronized 和 ReentrantLock
- Lone brave man
- 猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
- After Luke zettlemoyer, head of meta AI Seattle research | trillion parameters, will the large model continue to grow?
- Spark DF增加一列
- FFT learning notes (I think it is detailed)
- The relationship between FPGA internal hardware structure and code
- View class diagram in idea
- Gartner发布2022-2023年八大网络安全趋势预测,零信任是起点,法规覆盖更广
- 直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
猜你喜欢
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
Spark AQE
Four commonly used techniques for anti aliasing
After Luke zettlemoyer, head of meta AI Seattle research | trillion parameters, will the large model continue to grow?
JVM_ 15_ Concepts related to garbage collection
Comment faire votre propre robot
Finding the nearest common ancestor of binary search tree by recursion
MYSQL GROUP_ The concat function realizes the content merging of the same ID
ubantu 查看cudnn和cuda的版本
随机推荐
Pbootcms plug-in automatically collects fake original free plug-ins
Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
【第30天】给定一个整数 n ,求它的因数之和
DD's command
GNSS terminology
The value of applet containers
[groovy] JSON serialization (convert class objects to JSON strings | convert using jsonbuilder | convert using jsonoutput | format JSON strings for output)
Promise
Four dimensional matrix, flip (including mirror image), rotation, world coordinates and local coordinates
ubantu 查看cudnn和cuda的版本
Leetcode 44 Wildcard matching (2022.02.13)
Recursive method converts ordered array into binary search tree
STM32按键消抖——入门状态机思维
golang mqtt/stomp/nats/amqp
WordPress collection plug-in automatically collects fake original free plug-ins
[groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)
Keepalive component cache does not take effect
Live video source code, realize local storage of search history
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
如何制作自己的机器人