I knew boolean in mysql as tinyint (1)
.
Today I see a table with defined an integer like tinyint(2)
, and also others like int(4)
, int(6)
…
What does the size means in field of type integer and tinyint ?
MySQLsqldatatypes
I knew boolean in mysql as tinyint (1)
.
Today I see a table with defined an integer like tinyint(2)
, and also others like int(4)
, int(6)
…
What does the size means in field of type integer and tinyint ?
Best Answer
The
(m)
indicates the column display width; applications such as the MySQL client make use of this when showing the query results.For example:
Here
a
,b
andc
are usingTINYINT(1)
,TINYINT(2)
andTINYINT(3)
respectively. As you can see, it pads the values on the left side using the display width.It's important to note that it does not affect the accepted range of values for that particular type, i.e.
TINYINT(1)
still accepts[-128 .. 127]
.