日期:2014-05-17 浏览次数:20472 次
--创建测试表dbo.dny
create table dbo.dny(a int,b int,c int,d int,e int)
--添加not null约束
alter table dbo.dny alter column a int not null
--添加唯一约束
alter table dbo.dny add constraint uq_b unique (b)
--添加主键约束
alter table dbo.dny add constraint pk_a primary key (a)
--添加检查约束
alter table dbo.dny add constraint ck_c check(c between 0 and 100)
--添加外键约束
create table dbo.emz(f int constraint pk_emz primary key (f))
alter table dbo.dny add constraint fk_d foreign key (d) references dbo.emz(f)