the important thing is not to stop questioning

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
统计
 

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

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   qook  阅读(303)  评论(0编辑  收藏  举报
努力加载评论中...
 
点击右上角即可分享
微信分享提示