63

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.

Szekelygobe
  • 2,309
  • 1
  • 19
  • 25
  • 3
    I learned from your link: "display width do not affect the storage size of the data type". – gom Nov 10 '20 at 06:53

3 Answers3

72

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

Community
  • 1
  • 1
carusyte
  • 1,549
  • 17
  • 21
17

It means you should not specify the width of an integer value. Just write it as only int, not int(5).

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Ronak Raj
  • 181
  • 1
  • 2
12

The warning applies to all INT types: INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT. It means in future MySQL releases there will be no need to specify display length.

In my case it was TINYINT(1) that triggered the warning.

To prevent the warning, do: is_duplicate TINYINT instead of is_duplicate TINYINT(1)

Banty
  • 532
  • 6
  • 10