mysql约束条件
约束条件 (测试markdown 编辑器专用)
null 允许为空
not null 不允许为空
key 键值类型
default 设置默认类型,缺省值为NULL
extra 额外设置
CREATE TABLE dbname.tablename(
t_name CHAR(10) NOT NULL,
t_age tinyint unsigned default 20,
t_addr char(50) not null default "保密",
t_pay float(10,2) default 0.00
);
+--------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------------------+------+-----+---------+-------+
| t_name | char(10) | NO | | NULL | |
| t_age | tinyint(3) unsigned | YES | | 20 | |
| t_addr | char(50) | NO | | 保密 | |
| t_pay | float(10,2) | YES | | 0.00 | |
+--------+---------------------+------+-----+---------+-------+