"mysql - warning: #1681 integer display width is deprecated" Code Answer


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

By McKenzieG1 on August 26 2022

Answers related to “mysql - warning: #1681 integer display width is deprecated”

Only authorized users can answer the Search term. Please sign in first, or register a free account.