字段约束
约束条件
默认约束
create table 表名(id int default'100');
如果没有给id值就用100,如果添加的时候指定了就用指定的
非空约束
create table 表名(id int not null);
不能为空值,没有就报错
唯一约束
create table 表名(id int not unique key);
主键约束,就是非空加唯一
每张表只能设置一个主键
create table 表名(id int primary key);
自增长约束
字段约束
约束条件
默认约束
create table 表名(id int default'100');
如果没有给id值就用100,如果添加的时候指定了就用指定的
非空约束
create table 表名(id int not null);
不能为空值,没有就报错
唯一约束
create table 表名(id int not unique key);
主键约束,就是非空加唯一
每张表只能设置一个主键
create table 表名(id int primary key);
自增长约束