MySQL中int(5),int(10),int(11)有什么区别?

MySQL中int(5),int(10),int(11)有什么区别,我试了一下看不出来有啥区别呀,数据库版本是5.5.40

https://blog.csdn.net/baihao1961/article/details/101816977

int后面的是显示宽度,不是类型的实际宽度。

对于int型,在数据库中存储的长度永远是4个字节。

参考:https://dev.mysql.com/doc/refman/5.7/en/numeric-type-attributes.html

MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits. This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets. Whether it is used is up to the application.)

The display width does not constrain the range of values that can be stored in the column. Nor does it prevent values wider than the column display width from being displayed correctly. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range permitted by three digits are displayed in full using more than three digits.

When used in conjunction with the optional (nonstandard) ZEROFILL attribute, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.

你用select查询出来就知道区别了