the important thing is not to stop questioning

导航

 

假如我要为一个表中添加一个外键约束.语法如下

alter table  dbo.employee with check add constraint [FK_employeeno]  foreign key ([colorcode])

references  dbo.color([colorcode])

 

其中的with check /nocheck 的作用: 指定表中的数据是否用新添加的或者重新启用的foregin key 或者check 进行验证.


check :对添加验证之前的数据也进行验证检查.

nocheck :对添加之前的数据不进行验证检查,只对添加验证之后的数据进行检查.不提倡使用nocheck ,因为这样破坏了数据库中数据的一致性.

posted on 2015-10-16 11:28  qook  阅读(299)  评论(0编辑  收藏  举报