当前位置:   article > 正文

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

mysql 默认0和填充0

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)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/322362
推荐阅读
相关标签
  

闽ICP备14008679号