In summary, INT (m) zerofill, followed by zerofill, then M shows a little effect. For example, if int (3) zerofill is inserted into the database as 10, it is actually inserted as 010, that is, add a 0. if int (3) and INT (10) do not add zerofill, there is no difference between them. M is not used to limit the number of Int. the maximum and minimum values of INT (m) are related to undesigned values.
1 bytes = 8 bit. The maximum length of a byte can be 2 to the power of 8. 11111111 is also in the computer.
-128 to 127
1. Bit [m]
Bit Field type. M indicates the number of digits of each value, ranging from 1 to 64. If M is ignored, the default value is 1.
2. tinyint [(M)] [Unsigned] [zerofill] m is 4 by default
A small integer. The signed range is-128 to 127. The unsigned range is 0 to 255.
3. bool, Boolean
Is a synonym for tinyint (1. The zero value is considered false. The non-zero value is true.
4. smallint [(M)] [Unsigned] [zerofill] m is 6 by default
A small integer. The signed range is-32768 to 32767. The unsigned range is 0 to 65535.
5. mediumint [(M)] [Unsigned] [zerofill] m is 9 by default
An integer of medium size. The signed range is-8388608 to 8388607. The unsigned range is 0 to 16777215.
6. Int [(M)] [Unsigned] [zerofill] m is 11 by default
An integer of the normal size. The signed range is-2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
7. bigint [(M)] [Unsigned] [zerofill] m is 20 by default
A large integer. The signed range is-9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.
Note: Here m represents not the specific length stored in the database. In the past, I always mistakenly thought that int (3) can only store three numbers in length, INT (11) it stores 11 length numbers, which is a big mistake.
In fact, when we select the int type, whether it is int (3) or int (11), it stores 4 bytes in the database, when int (3) is used, if you input 10, the storage space 010 will be provided by default. That is to say, this 3 represents the default length, when you have less than three places, it will not help you. When you have more than three places, there will be no impact.
The day before yesterday, the Group Administrator asked me what is the difference between int (10) and INT (11). I thought it was the difference in length. Now, there is no difference between them in terms of storage. INT (10) can also represent the value of 2147483647 int (11.
To check the effect, remember to add the zerofill value when creating the type, indicating to fill it with 0; otherwise, the effect will not be displayed.
We usually do not add this option when creating databases, so there is no difference between them.
Difference between int (20) and INT (12)