ALTER TABLE Student --主键约束
ADD CONSTRAINT PK_StuNo PRIMARY KEY (StudentNo)

ALTER TABLE Student --唯一约束(身份证号唯一)
ADD CONSTRAINT UQ_stuID UNIQUE (IdentityCard)

ALTER TABLE Student --默认约束(地址不详)
ADD CONSTRAINT DF_stuAddress DEFAULT ('地址不详') FOR Address

ALTER TABLE Student --检查约束(出生日期是自1980年1月1日以后)
ADD CONSTRAINT CK_stuBornDate CHECK(BornDate>='1980-1-1')

ALTER TABLE Student --添加外键约束
ADD CONSTRAINT FK_Grade
FOREIGN KEY(GradeID) REFERENCES Grade(GradeID)
go

posted on 2015-07-03 11:07  吴仕华  阅读(783)  评论(0编辑  收藏  举报