Is there a difference in using INT(1) vs TINYINT(1) in MySQL?
Here you'll understand it in a better way!
tinyint: 1 byte, -128 to +127 / 0 to 255 (unsigned)
smallint: 2 bytes, -32,768 to +32,767 / 0 to 65,535 (unsigned)
mediumint: 3 bytes, -8,388,608 to 8,388,607 / 0 to 16,777,215 (unsigned)
int/integer: 4 bytes, -2,147,483,648 to +2,147,483,647 / 0 to 4,294,967,295 (unsigned)
bigint: 8 bytes, -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 / 0 to 18,446,744,073,709,551,615 (unsigned)
The number in parentheses for integer column types is the "display width". This does not effect the storage requirements as they are pre-defined.
Further reading
- http://dev.mysql.com/doc/refman/5.0/en/data-types.html
- http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
To summarize the accepted answered :
The number in parentheses indicates the *number of characters to display that field*, **not** the storage size of the field.
But if you want to know the storage size, you should check the MySQL source documents.
Source: MySQL Docs: Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT
Direct quote from source documentation :
TINYINT : 1 byte, -128 to 127 signed, 0 to 255 unsigned
SMALLINT : 2 bytes, -32768 to 32767 signed, 0 to 65535 unsigned
MEDIUMINT : 3 bytes, -8388608 to 8388607 signed, 0 to 16777215 unsigned
INT : 4 bytes, -2147483648 to 2147483647 signed, 0 to 4294967295 unsigned
BIGINT : 8 bytes, -2^63 to 2^63-1 signed, 0 to 2^64-1 unsigned