MYSQL-警告:#1681整数显示宽度已弃用 [英] MYSQL - Warning: #1681 Integer display width is deprecated

查看:2353
本文介绍了MYSQL-警告:#1681整数显示宽度已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在phpMyAdmin中导入mysql dumps时,出现此警告:

I'm getting this warning when importing mysql dumps in phpMyAdmin:

Warning: #1681 Integer display width is deprecated and will be removed in a future release.

我在 https://dev.mysql.com/worklog/task上找到了/?id = 13127

Deprecate the ZEROFILL attribute for numeric data types and the display width attribute for integer types.

但是我真的不明白这意味着什么.有人可以解释产生此警告的问题是什么,以及如何解决它.

but i don't really understand what it means. Can someone explain what is the problem generating this warning, and how to resolve it.

推荐答案

选中此数字类型属性以了解更完整的故事:

Check this Numeric Type Attributes for the much complete story:

MySQL支持扩展,可以有选择地在类型的基本关键字之后的括号中指定整数数据类型的显示宽度.例如,INT(4)指定显示宽度为四位数的INT.应用程序可以使用此可选的显示宽度来显示整数值,该整数值的宽度小于为列指定的宽度,方法是用空格左键填充它们. (也就是说,此宽度存在于结果集返回的元数据中.是否使用该宽度取决于应用程序.)

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.)

显示宽度不限制可以存储在列中的值的范围.也不会阻止宽于列显示宽度的值正确显示.例如,指定为SMALLINT(3)的列通常具有-32768到32767的SMALLINT范围,并且使用三位以上的数字完整显示三位数所允许的范围之外的值.

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.

因此,可以安全地忽略当前MySQL版本(撰写本文时为8.0.17)的此类警告.

So it shall be safe to ignore these kind of warning up to current version of MySQL (8.0.17 as of writing).

如果您想避免这些警告并安全起见,请将所有具有诸如INT(##)之类的列类型定义的受影响的表更新为INT(即,无需明确指定显示宽度).

If you'd like to avoid these warnings and play safe, update all your affected tables having column type definitions of something like INT(##) to INT (i.e. without explicitly specifying the display width).

这篇关于MYSQL-警告:#1681整数显示宽度已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆