当前位置:网站首页>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
边栏推荐
- Live video source code, realize local storage of search history
- NLP generation model 2017: Why are those in transformer
- Spark DF增加一列
- Dynamic programming -- linear DP
- Fibonacci number
- curlpost-php
- [groovy] XML serialization (use markupbuilder to generate XML data | create sub tags under tag closures | use markupbuilderhelper to add XML comments)
- FFT learning notes (I think it is detailed)
- Cf:h. maximum and [bit operation practice + K operations + maximum and]
- RAID disk redundancy queue
猜你喜欢
MCU realizes OTA online upgrade process through UART
What is the most suitable book for programmers to engage in open source?
WordPress collection plug-in automatically collects fake original free plug-ins
Introduction of motor
vSphere实现虚拟机迁移
Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
Arduino六足机器人
Convert binary search tree into cumulative tree (reverse middle order traversal)
Questions about database: (5) query the barcode, location and reader number of each book in the inventory table
ADS-NPU芯片架构设计的五大挑战
随机推荐
[simple implementation of file IO]
I'm interested in watching Tiktok live beyond concert
Folding and sinking sand -- weekly record of ETF
Five challenges of ads-npu chip architecture design
curlpost-php
esxi的安装和使用
Idea remotely submits spark tasks to the yarn cluster
KDD 2022 | 脑电AI助力癫痫疾病诊断
Gartner发布2022-2023年八大网络安全趋势预测,零信任是起点,法规覆盖更广
Distributed base theory
Browser reflow and redraw
Cf:c. the third problem
Kotlin core programming - algebraic data types and pattern matching (3)
Promise
【第30天】给定一个整数 n ,求它的因数之和
Xunrui CMS plug-in automatically collects fake original free plug-ins
Spark获取DataFrame中列的方式--col,$,column,apply
[groovy] XML serialization (use markupbuilder to generate XML data | create sub tags under tag closures | use markupbuilderhelper to add XML comments)
CTF daily question day44 rot
Ubantu check cudnn and CUDA versions