简体   繁体   English

SQL Server:此sql语句是什么意思

[英]SQL server: what does this sql statement mean

I've been comparing databases using vs 2010 scheme comparing tool and it generated some stuff which is not clear. 我一直在使用vs 2010方案比较工具比较数据库,它生成了一些不清楚的东西。 For example at the end of the script it has this statement: 例如,在脚本末尾具有以下语句:

ALTER TABLE [dbo].[My_table] WITH CHECK CHECK CONSTRAINT [FK_FOREIGN_ID];

Can anyone explain what this means? 谁能解释这意味着什么?

It means that existing data should be checked against the constraint when it is added. 这意味着添加现有数据时,应对照约束条件对其进行检查。

Failure to have the CHECK CHECK leaves your constraints untrusted and they cannot be used by the query optimiser. 未能执行CHECK CHECK会使您的约束不受信任,并且查询优化程序无法使用它们。

That tells SQL Server to validate the constraint against new rows. 这告诉SQL Server验证对新行的约束。 The counter example would be to use WITH NOCHECK to temporarily disable validation checks for new rows. 相反的示例是使用WITH NOCHECK暂时禁用对新行的验证检查。

ALTER TABLE (Transact-SQL) (WITH CHECK | WITH NOCHECK ) ALTER TABLE(Transact-SQL)(选中| WITH NOCHECK)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM