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?
BIGINT
?BIGINT takes 8 bytes i.e. 64 bits. The signed range is -9223372036854775808 to 9223372036854775807 and unsigned range takes positive value. The range of unsigned is 0 to 18446744073709551615.
Standard integer value. Signed values range from -2147483648 to 2147483647. Unsigned values range from 0 to 4294967295. This is a synonym for the INT datatype.
BIGINT is the MySQL data type that can be assigned to the columns of the table in which we want to store the whole numbers and we are aware that the range of the numbers that we will store in that column will be huge and not exceed the range of the BIGINT data type.
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).
You answer is in this overview. A BIGINT is indeed 8 bytes. A TinyInt only 1.
Btw, I don't consider the range from -9223372036854775808
to 9223372036854775807
very embarrassing, it's +/-2^63 :).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With