关于mysql一些数据类型长度无法修改,如int类型长度强制为0的情况的一些解释

前言

根据公司需求,写了几个新表,然后发现个别字段,如TINYINT, SMALLINT, MEDIUMINT, INT等类型会出现字段长度为0的情况,然后无论怎么修改都是无济于事。

原因

MySQL Server 8.0.17 deprecated the display width for the TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT data types when the ZEROFILL modifier is not used, and MySQL Server 8.0.19 has removed the display width for those data types from results of SHOW CREATE TABLE, SHOW CREATE FUNCTION, and queries on INFORMATION_SCHEMA.COLUMNS, INFORMATION_SCHEMA.ROUTINES, and INFORMATION_SCHEMA.PARAMETERS (except for the display width for signed TINYINT(1)). This patch adjusts Connector/J to those recent changes of MySQL Server and, as a result, DatabaseMetaData, ParameterMetaData, and ResultSetMetaData now report identical results for all the above-mentioned integer types and also for the FLOAT and DOUBLE data types. (Bug #30477722)

翻译过来的意思就是:

从8.0.17版本开始,TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT类型的显示宽度将失效。

所以才会出现上面说的几个类型无法修改长度。但是这个并不影响我们表的使用,基本上是可以忽略掉的细节!
完事跑路!

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐