日期:2014-05-16  浏览次数:20619 次

为什么数据类型定为某一种整型还要声名长度?
比如TINYINT是-128~127或0~255,那再声明数据的时候声明成 TINYINT(5)还有什么意义?如果说说明是5位,那么TINYINT (5)和INT(5)有什么区别?

------解决方案--------------------
TINYINT (5)和tinyint得存储是一模一样的 

如果列定义不加zerofill也是一样的


加了zerofill不同之处在于客户端显示的时候 加长度得会自动补齐指定位的0

mysql> create table test_1(a int)
Query OK, 0 rows affected (1.22 s

mysql> insert into test_1 values(
Query OK, 1 row affected (0.17 se

mysql> create table test_1(a int(
ERROR 1050 (42S01): Table 'test_1
mysql> create table test_2(a int(
Query OK, 0 rows affected (0.20 s

mysql> insert into test_2 values(
Query OK, 1 row affected (0.08 se

mysql> select * from test_1;
+------+
| a |
+------+
| 1 |
+------+
1 row in set (0.03 sec)

mysql> select * from test_2;
+-------+
| a |
+-------+
| 00001 |
+-------+
1 row in set (0.06 sec)

mysql>