项目场景:
使用navicat客户端对mysql数据库表的个别字段类型设置长度
问题描述
设置完长度后,点击保存,发现int类型和tinyint(1除外)等类型设置的长度都变为0
原因分析:
查找官网相关资料,发现MySQL Server 8.0.17已移除TINYINT、SMALLINT、MEDIUMINT、INT和BIGINT数据类型的显示宽度,并且MySQL Server 8.0.19已从SHOW CREATE TABLE、SHOW CREATE FUNCTION和INFORMATION_SCHEMA查询结果中移除这些数据类型的显示宽度。
官网相关资料:
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)
这下你知道navicat客户端对个别字段类型设置长度保存后变为0的原因了吧。