1 and smallint represent integer data from-215 (-32,768) to 215-1(32,767). Unsigned is from 0 to? Integer data of 65535.
Therefore, when building a table, it can only be smallint(5), even if smallint( 100) is built, the maximum number is still as many as 5 digits.
2.int represents integer data (all) from -2 3 1 (-2,147,483,648) to 2 3 1- 1 (2,147,483,647). Integer data of 4294967296.
Therefore, when building a table, it can only be int( 10). Even if it is built int( 100), the maximum number is 10.
Second, the storage size is different.
Smallint storage size is 2 bytes, and int storage size is 4 bytes.
Int(M) In integer data type, m represents the maximum display width. In int(M), the value of m has nothing to do with the storage space occupied by int(M). Int(3), int(4) and int(8) all occupy 4 btyes storage space on the disk.
Extended data:
Mysql provides five types of integers: tinyint, smallint, mediumint, int and bigint. Int is short for integer. These types are different in the range of representable values.
Integer columns can be defined as unsigned to disable negative values; This makes the value range of this column greater than 0. Various types of storage requirements are also different. Types with a wide range of values require more storage space.
Mysql provides three floating-point types: float, double and decimal. Unlike integers, floating-point types cannot be unsigned, and their range of values is also different from integers. The difference is that these types have not only the maximum value, but also the minimum non-zero value.
The minimum value provides a measure of the corresponding type of accuracy, which is very important for recording scientific data (of course, there are also negative maximum and minimum values).
Baidu encyclopedia -—int
Baidu encyclopedia -—smallint