mysql tinyint(1) vs tinyint(2) vs tinyint(3) vs tinyint(4)
MysqlMysql Problem Overview
> Possible Duplicate:
> MySql: Tinyint (2) vs tinyint(1) - Which difference?
What is the difference between:
TinyINT(1)
TinyINT(2)
TinyINT(3)
TinyINT(4)
Mysql Solutions
Solution 1 - Mysql
TinyINT(M) always has a range from -128..+127 signed or 0..255 unsigned. M is the display width.
> M indicates the maximum display width for integer types. The maximum > display width is 255. Display width is unrelated to the range of > values a type can contain, as described in Section 11.2, “Numeric > Types”. For floating-point and fixed-point types, M is the total > number of digits that can be stored.
from http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html
Solution 2 - Mysql
According to Mysql manual all decimal numeric types supports syntax:
Integer Types (Exact Value)
When using DECIMAL
it allows you to specify precision.
With *INT
types it's has mainly display function which also specifies how many places should be added when using ZEROFILL
.
The byte size remains unaffected (1B
for TINYINT
).
Solution 3 - Mysql
TinyINT = -128...+127
(n) is for display purposes.