模板:
CREATE TABLE 表名 (
字段名1 字段类型1 约束条件1 说明1,
字段名2 字段类型2 约束条件2 说明2,
字段名3 字段类型3 约束条件3 说明3
);
约束条件:
comment ----说明解释
not null ----不为空
default ----默认值
unsigned ----无符号(即正数)
auto_increment ----自增
zerofill ----自动填充
unique key ----唯一值
注意:
1.参数最后都要加上‘,’英文逗号这个符号。
2.comment与’ ’ 符号之间要有空格。
示例:
create table student(
id tinyint(3) zerofill auto_increment not null comment ‘学生学号’,
name varchar(20) default null comment ‘学生名字’,
age tinyint default null comment ‘年龄’,
sex char(5) default null comment ‘性别’,
unique key (id)
);