侧边栏壁纸
  • 累计撰写 49 篇文章
  • 累计创建 23 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Mysql8.0.17后Int类型不再推荐设置长度了

阿砖
2024-06-09 / 0 评论 / 0 点赞 / 249 阅读 / 2164 字

今天在用 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

0

评论区