数据库约束

默认值、非空、主键、唯一、自增长、外键

默认值:

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

posted on 2019-09-02 11:02  流光若影  阅读(96)  评论(0)    收藏  举报