I was wondering what the difference between BigInt
, MediumInt
, and Int
are... it would seem obvious that they would allow for larger n
The number in parentheses in a type declaration is display width, which is unrelated to the range of values that can be stored in a data type. Just because you can declare Int(20)
does not mean you can store values up to 10^20 in it:
[...] 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. ...
The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range allowed by three characters are displayed using more than three characters.
For a list of the maximum and minimum values that can be stored in each MySQL datatype, see here.