Mysql – Is BIGINT(8) the largest integer MySQL can store

MySQLsql

I've got some numbers that is now larger than INT can handle.

This is a bit embarrassing, but I honestly don't know exactly what the BIGINT(8) means. Is the 8 in that the max bit value or the max length?

So BIGINT(1) can only be one digit? Or is BIGINT(1) something else? I think TINYINT(1) max is 127, how does that work out?

  • What is the biggest I can make BIGINT?
  • What is the largest number I can store in MySQL as an integer?

Best Answer

The number represents how it's displayed - it doesn't affect how the data is stored.

From the manual:

Another extension is supported by MySQL for optionally specifying the display width of integer data types in parentheses following the base keyword for the type (for example, INT(4)). 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 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.

A BIGINT is always 8 bytes and can store -9223372036854775808 to 9223372036854775807 (signed) or 0 to 18446744073709551615 (unsigned).