Http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/08/25/2153016.html
What is the difference between MySQL int (1) tinyint (1)?
I have specified the field length, does the type still make sense? The reply:mysql in int (1) and tinyint (1) only specify the display length and do not represent the storage length, only the field designation Zerofill is useful
such as int (3), if the actual value is 2, if the column specifies Zerofill, the query result is 002, the left is filled with zeros. tinyint[(M)] [UNSIGNED] [Zerofill]
A very small integer. The signed range is-128 to 127. The unsigned range is 0 to 255.
int[(M)] [UNSIGNED] [Zerofill]
A normal-size Integer. The signed range is-2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
The limit of the digits is basically meaningless.
Mysql> CREATE TABLE Testint (id int (1), col2 tinyint (1));
Query OK, 0 rows affected (0.06 sec)
mysql> INSERT into Testint values (256, 257);
Query OK, 1 row affected, 1 warning (0.03 sec)
Mysql> select * from Testint;
+------+------+
| ID | col2 |
+------+------+
| 256 | 127 |
+------+------+
1 row in Set (0.02 sec)
mysql> INSERT into Testint values (336, 257);
Query OK, 1 row affected, 1 Warning (0.02 sec)
Mysql> select * from Testint;
+------+------+
| ID | col2 |
+------+------+
| 256 | 127 |
| 336 | 127 |
+------+------+
2 rows in Set (0.00 sec)
mysql> INSERT into Testint values (336, 255);
Query OK, 1 row affected, 1 warning (0.03 sec)
Mysql> select * from Testint;
+------+------+
| ID | col2 |
+------+------+
| 256 | 127 |
| 336 | 127 |
| 336 | 127 |
+------+------+
3 Rows in Set (0.00 sec)
Mysql>
Take a look at the warning tips above ....
----------------------------MySQL true, what data type should be used for such data? Reply:tinyint (1)
What is the difference between MySQL int (1) and tinyint (1)?