当前位置:网站首页>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 .
边栏推荐
- Hunan University | robust Multi-Agent Reinforcement Learning in noisy environment
- [turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration
- MPLS③
- In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
- Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.
- On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
- MySQL introduction - functions (various function statistics, exercises, details, tables)
- Install the pit that the electron has stepped on
- Luogu p1309 Swiss wheel
- Software product download collection
猜你喜欢

LV1 previous life archives

Douban scoring applet Part-3

High level application of SQL statements in MySQL database (I)

How can enterprises optimize the best cost of cloud computing?
![[leetcode daily question] a single element in an ordered array](/img/3a/2b465589b70cd6aeec08e79fcf40d4.jpg)
[leetcode daily question] a single element in an ordered array

SQL statement

A fan summed up so many interview questions for you. There is always one you need!

Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.

Huawei rip and BFD linkage

Three layer switching ②
随机推荐
Override and virtual of classes in C #
In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
Question C: Huffman tree
Openbionics exoskeleton project introduction | bciduino community finishing
Logical operator, displacement operator
Customize redistemplate tool class
Final consistency of MESI cache in CPU -- why does CPU need cache
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
The contact data on Jerry's management device supports reading and updating operations [articles]
Hbuilder link Xiaoyao simulator
Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
Development of user-defined navigation bar in uniapp
The automatic control system of pump station has powerful functions and diverse application scenarios
Do you know the eight signs of a team becoming agile?
What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
Idea if a class cannot be found, it will be red
Huawei cloud micro certification Huawei cloud computing service practice has been stable
ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
C import Xls data method summary III (processing data in datatable)
Pyrethroid pesticide intermediates - market status and future development trend