[SOLVED] MYSQL – Warning: #1681 Integer display width is deprecated

Issue

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.

Solution

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

Answered By – carusyte

Answer Checked By – Dawn Plyler (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.