数据库约束

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

默认值:

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

原文地址:https://www.cnblogs.com/god3064371/p/11445361.html