color:red

约束定义语法

 

约束定义语法错误
--主健约束 (stuNo作为主健)
alter table stuInfo
add constraint PK_stuNo primary key(stuNo)
--唯一约束 (身份证号)
alter table stuInfo
add constraint UQ_stuID unique (stuID)
--默认约束 (如果地址不填,默认“地址不详”)
alter table stuInfo
add constraint DF_stuAddress default('地址不详')
--检查 要求年龄在15-40之间
alter table stuInfo
add constraint CK_stuAge check (stuAge between 15 and 40)
--外健 (主表stuInfo和从表stuMarks建立关系, 关联字段为stuNo)
alter table stuMarks
add constraint FK_stuNo foreign key(stuNo) references stuInfo(stuNo)
go
默认约束那里的语法出错了。。
你没有为默认约束指定列名
正确的写法为:
alter table stuifo
add constraint DF_stuaddress defalut('地址不详') for stuaddress(字段名) 

 

posted on 2010-06-17 13:55  永不言弃program  阅读(346)  评论(0编辑  收藏  举报

导航

color:red