mysql 里面零填充和默认值属性:zerofill default 属性



mysql 里面零填充和默认值属性:zerofill default 属性


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> desc shop;
+---------+--------------------------+------+-----+---------+-------+
| Field     | Type                   | Null | Key | Default | Extra |
+---------+--------------------------+------+-----+---------+-------+
| article | int(4) unsigned zerofill | NO   | PRI | 0000    |       |
| dealer    | char(20)               | NO   | PRI |         |       |
| price     | double(16,2)           | NO   |     | 0.00    |       |
+---------+--------------------------+------+-----+---------+-------+
 mysql> select * from shop;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
|    0001 | A      |  3.45 |
|    0001 | B      |  3.99 |
|    0002 | A      | 10.99 |
|    0003 | B      |  1.45 |
|    0003 | C      |  1.69 |
|    0003 | D      |  1.25 |
|    0004 | D      | 19.95 |
+---------+--------+-------+
7 rows in set (0.00 sec)
mysql> insert into shop values('','','');
Query OK, 1 row affected, 2 warnings (0.01 sec)
mysql> select * from shop;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
|    0001 | A      |  3.45 |
|    0001 | B      |  3.99 |
|    0002 | A      | 10.99 |
|    0003 | B      |  1.45 |
|    0003 | C      |  1.69 |
|    0003 | D      |  1.25 |
|    0004 | D      | 19.95 |
|    0000 |        |  0.00 |
+---------+--------+-------+
8 rows in set (0.00 sec)
 
 

你可能感兴趣的:(mysql,table,null,query,insert,Warnings)