mysql-zerofill关键字

zerofill位数填充

mysql> create table shop(
    -> article int(4) unsigned zerofill default 0000 not null,
    -> dealer char(20) default ‘‘ not null,
    -> price double(16,2) default 0.00 not null,
    -> primary key(article,dealer));

mysql> insert into shop values(1,A,3.45),(1,B,3.99),(2,A,10.99),(3,B,1.4
5),(3,C,1.69),(3,D,1.25),(4,D,19.95);
Query OK, 7 rows affected (0.01 sec)
Records: 7  Duplicates: 0  Warnings: 0

mysql> select * from shop;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
|    0001 | A      |  3.45 |
|    0001 | B      |  3.99 |
|    0002 | A      | 10.99 |