比如TINYINT是-128~127或0~255,那再声明数据的时候声明成 TINYINT(5)还有什么意义?如果说说明是5位,那么TINYINT (5)和INT(5)有什么区别?

解决方案 »

  1.   

    TINYINT (5)和tinyint得存储是一模一样的 如果列定义不加zerofill也是一样的
    加了zerofill不同之处在于客户端显示的时候 加长度得会自动补齐指定位的0mysql> create table test_1(a int)
    Query OK, 0 rows affected (1.22 smysql> insert into test_1 values(
    Query OK, 1 row affected (0.17 semysql> 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 smysql> insert into test_2 values(
    Query OK, 1 row affected (0.08 semysql> 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>