TINYINT[(M)] [UNSIGNED] [ZEROFILL]
A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
INT[(M)] [UNSIGNED] [ZEROFILL]
A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
The 'M' is the maximum display width. However, this does NOT limit the range of values that can be stored in this column.
由此可见,位数限制只影响读出来的数怎么展示。mysql 中int(M)和tinyint(M)中的M 表示最大显示宽度,并不表示存储长度,只有字段指定zerofill时有意义。如int(3),若实际值是2且列指定了zerofill,查询结果就是002,左边用0来填充。 int(3)、int(4)、int(8) 在磁盘上都是占用 4 btyes 的存储空间。bigint[M]中M的含义也是这样。