In MySQL table definitions is there a different between
SMALLINT(5)? Or do they both represent the same size?
int and a
smallint have different sizes and consequently ranges.
int(5) is called a "Numeric Type Attribute" and it represents the "display width" of the field,
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,
INTwith 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.)
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
5is retrieved as
This is a MySQL "extension", and zerofill is an "extension" on an extension.
For the sane method of controlling the display of a numeric type, don't ues Numeric type Attributes and instead use