Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 540
Szekelygobe Avatar asked Nov 19 '19 16:11

Szekelygobe


People also ask

How can I see MySQL warnings?

The mysql client also has a number of options related to warnings. The \W command will show warnings after every statement, while \w will disable this. Starting the client with the --show-warnings option will show warnings after every statement.

How do I stop MySQL warnings?

To suppress warnings, set SQL_NOTES=0.

What is the command to see warning messages?

Correct Option: B The SHOW WARNINGS command is used after executing one of those statements to see the warning messages.

What is MySQL error?

Lost connection to MySQL server Network conditions should be checked if this is a frequent error. If an error message like “Lost connection to MySQL server” appears while querying the database, it is certain that the error has occurred because of network connection issues.


1 Answers

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

like image 87
carusyte Avatar answered Sep 28 '22 04:09

carusyte