数据库约束
时间:2019-09-02 11:46:02
收藏:0
阅读:82
默认值、非空、主键、唯一、自增长、外键
默认值:
create table xx(
sname varchar(20) default ‘yyyy‘
)
非空:
create table xx(
sname varchar(20) not null
)
唯一:
create table xx(
sname varchar(20) unique
)
主键:非空且唯一
create table xx(
sid int primary key
)
自增长:auto_increment
create table xx(
sid int primary key auto_increment
)
0填充sid
sid int(3) zerofill primary key auto_increment
评论(0)