MySQL and Integers

Posted: June 26th, 2009 | Author: | Filed under: MySQL | Tags: | Comments Off on MySQL and Integers

Also tired of always looking up the minimum and/or maximum value of a MySQL integer field? For once and for all a cheatsheet:

Field type Bytes Attribute Min. value Max. value
TINYINT 1 -128 (-2^7) 127 (2^7 – 1)
TINYINT 1 UNSIGNED 0 255 (2^8 – 1)
SMALLINT 2 -32768 (-2^15) 32767 (2^15 – 1)
SMALLINT 2 UNSIGNED 0 65535 (2^16 – 1)
MEDIUMINT 3 -8388608 (-2^23) 8388607 (2^23 – 1)
MEDIUMINT 3 UNSIGNED 0 16777215 (2^24 – 1)
INT 4 -2147483648 (-2^31) 2147483647 (2^31 – 1)
INT 4 UNSIGNED 0 4294967295 (2^32 – 1)
BIGINT 8 -9223372036854775808 (-2^63) 9223372036854775807 (2^63 – 1)
BIGINT 8 UNSIGNED 0 18446744073709551615 (2^64 – 1)