mysql5.5 表列顯示寬度的修改_binary(x)

wisdomone1發表於2010-06-21
mysql> desc t1;
+-------+------------+------+-----+---------+-------+
| Field | Type       | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| a     | bit(1)     | YES  |     | NULL    |       |
| b     | tinyint(4) | YES  |     | NULL    |       |
| c     | binary(1)  | YES  |     | NULL    |       |    #binary預設顯示寬度為1
+-------+------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> alter table t1 modify c binary(30);#修改顯示寬度為30
Query OK, 5 rows affected (0.04 sec)
Records: 5  Duplicates: 0  Warnings: 0
mysql> select * from t1;#查詢發現修改binary顯示寬度前的列還是僅顯示第一個字母,也就是顯示寬度為1
+------+------+--------------------------------+
| a    | b    | c                              |
+------+------+--------------------------------+
|     | -127 | NULL                           |
|     |  127 | NULL                           |
|      |   28 | NULL                           |
|     |   18 | NULL                           |
|      |   10 | m                              |
+------+------+--------------------------------+
5 rows in set (0.00 sec)
mysql> insert into t1 values(0,25,'mama haha');#再次插入資料
Query OK, 1 row affected (0.00 sec)
mysql> select * from t1;
+------+------+--------------------------------+
| a    | b    | c                              |
+------+------+--------------------------------+
|     | -127 | NULL                           |
|     |  127 | NULL                           |
|      |   28 | NULL                           |
|     |   18 | NULL                           |
|      |   10 | m                              |
|      |   25 | mama haha                      |  #再次插入新行,全部binary列值顯示出來
+------+------+--------------------------------+
6 rows in set (0.00 sec)
mysql> insert into t1 values(0,18,'the best one is you');
Query OK, 1 row affected (0.00 sec)
mysql> select * from t1;
+------+------+--------------------------------+
| a    | b    | c                              |
+------+------+--------------------------------+
|     | -127 | NULL                           |
|     |  127 | NULL                           |
|      |   28 | NULL                           |
|     |   18 | NULL                           |
|      |   10 | m                              |
|      |   25 | mama haha                      |
|      |   18 | the best one is you            |
+------+------+--------------------------------+
7 rows in set (0.01 sec)
 
 
 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-665763/,如需轉載,請註明出處,否則將追究法律責任。

相關文章