今天在用 navicat 修改一张表的字段类型 int 的长度时候发现修改不了。
如果用修改命令强行修改这个字段的长度,提示执行有一个错误。
mysql> alter table articles modify column status int(10);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 1
去查询这个 warning 可以看到下面的内容
mysql> show warnings;
+---------+------+------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------------------------------+
| Warning | 1681 | Integer display width is deprecated and will be removed in a future release. |
+---------+------+------------------------------------------------------------------------------+
1 row in set (0.03 sec)
Integer display width is deprecated and will be removed in a future release.
这个错误提示我整数显示宽度已弃用,并将在将来的版本中删除,看起来在 8.0 之后改了什么。经过查资料发现 Mysql 8.0.17 之后 ZEROFILL 属性对于 int 类型已经弃用,而宽度也是基于 ZEROFILL 属性用来填充 0 的。所以在 ZEROFILL 弃用后相对于的宽度也就弃用了。
参考文献:
[1] https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html
评论区