设置非空约束
USE CSDN
alter table csdn alter column c1 int not null
设置主键
USE CSDN
alter table csdn add constraint pk primary key(c1)
设置取值范围
USE CSDN
alter table csdn add constraint ck check(c1>=0 AND c1<=100)
设置默认值
USE CSDN
alter table csdn add constraint de default(‘网络工程’)for c2
引入外键
USE CSDN
alter table css add constraint fk foreign key (c1) references csdn(c1)
删除约束
以删除 css表的外键约束为例:
USE CSDN
alter table css drop constraint fk