mysql zero fill_mysql zerofill 的使用
mysql zerofill的使用:
那這個int[M]中M是什么意義喃,在定義數(shù)值型數(shù)據(jù)類型的時候,可以在關(guān)鍵字括號內(nèi)指定整數(shù)值(如:int(M),M的最大值為255)顯示最大顯示寬度,顯示寬度M與數(shù)據(jù)所占用空間,數(shù)值的范圍無關(guān)。 如果在定義字段的時候指定zerofill,那么當數(shù)值的顯示寬度小于指定的列寬度時候,則默認補充的空格用0代替。
mysql> create table int_12(id int(12) zerofill);
Query OK, 0 rows affected (0.13 sec)
mysql> desc int_12;
+-------+---------------------------+------+-----+---------+-------+
| Field | Type ? ? ? ? ? ? ? ? ? ? ?| Null | Key | Default | Extra |
+-------+---------------------------+------+-----+---------+-------+
| id ? ?| int(12) unsigned zerofill | YES ?| ? ? | NULL ? ?| ? ? ? |
+-------+---------------------------+------+-----+---------+-------+
1 row in set (0.01 sec)
mysql> insert into int_12 (id) values(1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from int_12;
+--------------+
| id ? ? ? ? ? |
+--------------+
| 000000000001 |
+--------------+
1 row in set (0.00 sec)
mysql> alter table int_12 change id id int(23) zerofill;
Query OK, 0 rows affected (0.04 sec)
Records: 0 ?Duplicates: 0 ?Warnings: 0
mysql> select * from int_12;
+-------------------------+
| id ? ? ? ? ? ? ? ? ? ? ?|
+-------------------------+
| 00000000000000000000001 |
+-------------------------+
1 row in set (0.00 sec)
注意在navicate或者phpmyadmin中顯示數(shù)據(jù)顯示可能不正確,如果你加了zerofill,但是沒有補充0,可以到mysql命令行中看下
總結(jié)
以上是生活随笔為你收集整理的mysql zero fill_mysql zerofill 的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 8核16g参数优化_问个 M
- 下一篇: 守望先锋抢点新地图Ilios 爱琴海沿岸