当前位置:网站首页>The difference between int (1) and int (10)
The difference between int (1) and int (10)
2022-07-04 01:59:00 【South wind knows easy***】
We know that mysql in int Occupy 4 Bytes , So for unsigned int, The maximum is 2^32-1 = 4294967295, nearly 40 Billion , Did you use it int(1), Can't you reach this maximum ?
CREATE TABLE `user` (
`id` int(1) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
id The field is unsigned int(1), Let me insert a maximum to see .
mysql> INSERT INTO `user` (`id`) VALUES (4294967295);
Query OK, 1 row affected (0.00 sec)
You can see the success , explain int Back number , No effect int Size supported by itself ,int(1)、int(2)…int(10) No difference .
commonly int Back number , coordination zerofill It works when used together . Let's take an example :
CREATE TABLE `user` (
`id` int(4) unsigned zerofill NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
mysql> INSERT INTO `user` (`id`) VALUES (1),(10),(100),(1000);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
Insert separately 1、10、100、1000 4 Data , Then let's check :
mysql> select * from user;
+------+
| id |
+------+
| 0001 |
| 0010 |
| 0100 |
| 1000 |
+------+
4 rows in set (0.00 sec)
Through the data, we can find int(4) + zerofill Realized the deficiency 4 Place complement 0 The phenomenon of , only int(4) It's no use .
边栏推荐
- Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
- A. ABC
- MySQL introduction - functions (various function statistics, exercises, details, tables)
- Feign implements dynamic URL
- Hunan University | robust Multi-Agent Reinforcement Learning in noisy environment
- LV1 Roche limit
- A. Min Max Swap
- Is Shengang securities company as safe as other securities companies
- Basic editing specifications and variables of shell script
- Use classname to modify style properties
猜你喜欢
Mysql-15 aggregate function
2020-12-02 SSM advanced integration Shang Silicon Valley
Remember a lazy query error
Three layer switching ②
Bacteriostatic circle scanning correction template
How programmers find girlfriends through blind dates
Do you know the eight signs of a team becoming agile?
Jerry's synchronous weather information to equipment [chapter]
What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
随机推荐
2022 electrician (elementary) examination question bank and electrician (elementary) simulation examination question bank
Logical operator, displacement operator
Infiltration learning diary day19
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
Force buckle day32
MySQL deadly serial question 2 -- are you familiar with MySQL index?
IPv6 experiment
Three layer switching ②
Make drop-down menu
Huawei rip and BFD linkage
Neo4j learning notes
Portapack application development tutorial (XVII) nRF24L01 launch C
Development of user-defined navigation bar in uniapp
After listening to the system clear message notification, Jerry informed the device side to delete the message [article]
Mobile phone battery - current market situation and future development trend
Idsia & supsi & usi | continuous control behavior learning and adaptive robot operation based on Reinforcement Learning
Day05 branch and loop (II)
Final consistency of MESI cache in CPU -- why does CPU need cache
Gnupg website
Huawei cloud micro certification Huawei cloud computing service practice has been stable