2 replaced http://dba.stackexchange.com/ with https://dba.stackexchange.com/
source | link

As explained in this answer to a very similar questionthis answer to a very similar question, the "length" is a hint, provided in result set metadata for applications that want it, of the "typical" maximum number of digits expected to be seen in the column. As documented, this doesn't change the storage requirements and does not change the range of values that can be stored in a column.

As far as I know, this is essentially a holdover from the early evolution of MySQL when fixed-width terminals were common.

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 or not 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.

When used in conjunction with the optional (nonstandard) attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.

http://dev.mysql.com/doc/refman/5.6/en/numeric-type-attributes.html

As explained in this answer to a very similar question, the "length" is a hint, provided in result set metadata for applications that want it, of the "typical" maximum number of digits expected to be seen in the column. As documented, this doesn't change the storage requirements and does not change the range of values that can be stored in a column.

As far as I know, this is essentially a holdover from the early evolution of MySQL when fixed-width terminals were common.

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 or not 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.

When used in conjunction with the optional (nonstandard) attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.

http://dev.mysql.com/doc/refman/5.6/en/numeric-type-attributes.html

As explained in this answer to a very similar question, the "length" is a hint, provided in result set metadata for applications that want it, of the "typical" maximum number of digits expected to be seen in the column. As documented, this doesn't change the storage requirements and does not change the range of values that can be stored in a column.

As far as I know, this is essentially a holdover from the early evolution of MySQL when fixed-width terminals were common.

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 or not 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.

When used in conjunction with the optional (nonstandard) attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.

http://dev.mysql.com/doc/refman/5.6/en/numeric-type-attributes.html

1
source | link

As explained in this answer to a very similar question, the "length" is a hint, provided in result set metadata for applications that want it, of the "typical" maximum number of digits expected to be seen in the column. As documented, this doesn't change the storage requirements and does not change the range of values that can be stored in a column.

As far as I know, this is essentially a holdover from the early evolution of MySQL when fixed-width terminals were common.

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 or not 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.

When used in conjunction with the optional (nonstandard) attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.

http://dev.mysql.com/doc/refman/5.6/en/numeric-type-attributes.html