当前位置:网站首页>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边栏推荐
- Spark SQL空值Null,NaN判断和处理
- 程序员搞开源,读什么书最合适?
- Convert binary search tree into cumulative tree (reverse middle order traversal)
- cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】
- The inconsistency between the versions of dynamic library and static library will lead to bugs
- The detailed page returns to the list and retains the original position of the scroll bar
- How to extract MP3 audio from MP4 video files?
- 【第30天】给定一个整数 n ,求它的因数之和
- Dynamic programming -- linear DP
- 看抖音直播Beyond演唱会有感
猜你喜欢

MYSQL GROUP_ The concat function realizes the content merging of the same ID

The third season of ape table school is about to launch, opening a new vision for developers under the wave of going to sea

Introduction of motor
![[groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)](/img/e4/a41fe26efe389351780b322917d721.jpg)
[groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)

Browser reflow and redraw

图解网络:TCP三次握手背后的原理,为啥两次握手不可以?

Finding the nearest common ancestor of binary tree by recursion

Folding and sinking sand -- weekly record of ETF

SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑
![[groovy] JSON serialization (convert class objects to JSON strings | convert using jsonbuilder | convert using jsonoutput | format JSON strings for output)](/img/52/021931181ad3f4bef271b4e98105c2.jpg)
[groovy] JSON serialization (convert class objects to JSON strings | convert using jsonbuilder | convert using jsonoutput | format JSON strings for output)
随机推荐
How to make your own robot
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
Dedecms plug-in free SEO plug-in summary
Recoverable fuse characteristic test
猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
Illustrated network: the principle behind TCP three-time handshake, why can't two-time handshake?
Beginner redis
如何制作自己的机器人
Live video source code, realize local storage of search history
[groovy] XML serialization (use markupbuilder to generate XML data | create sub tags under tag closures | use markupbuilderhelper to add XML comments)
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
Cf:c. the third problem
Starting from 1.5, build a micro Service Framework - call chain tracking traceid
Kotlin core programming - algebraic data types and pattern matching (3)
Arduino六足机器人
MYSQL GROUP_ The concat function realizes the content merging of the same ID
[groovy] compile time meta programming (AST syntax tree conversion with annotations | define annotations and use groovyasttransformationclass to indicate ast conversion interface | ast conversion inte
Getting started with devkit
Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
[groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)