主键约束
alter table 表名 add constraint PK_约束名 primary key (主键)
【说明】主键不一定是只有一列,可以设置复合主键
alter table 表名 add constraint PK_约束名 primary key (列1,列2)
外键约束
alter table 外键表 add constraint FK_外键表_主键表 foreign key(外键) references 主键表(主键)
Check约束
alter table 表名 add constraint CK_约束名 check (约束表达式,如: Sex = '男' or Sex = '女')
唯一约束
alter table 表名 add constraint UQ_约束名 unique(唯一列)
默认值约束
alter table 表名 add constraint DK_约束名 default ('默认值') for 列
删除约束
alter table 表名 drop constraint 约束名