mysql1681_MYSQL - Warning: #1681 Integer display width is deprecated

问题

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.

I found this on 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.

回答1:

Check this Numeric Type Attributes for the much complete story:

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

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.

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

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

来源:https://stackoverflow.com/questions/58938358/mysql-warning-1681-integer-display-width-is-deprecated

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值