SQL server:这个SQL语句是什么意思

时间:2022-03-11 22:33:58

I've been comparing databases using vs 2010 scheme comparing tool and it generated some stuff which is not clear. For example at the end of the script it has this statement:

我一直在使用vs 2010方案比较工具对数据库进行比较,它产生了一些不清楚的东西。例如,在脚本的末尾有这样的语句:

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

Can anyone explain what this means?

谁能解释一下这是什么意思吗?

2 个解决方案

#1


3  

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.

检查失败会使约束不受信任,查询optimiser不能使用它们。

#2


1  

That tells SQL Server to validate the constraint against new rows. The counter example would be to use WITH NOCHECK to temporarily disable validation checks for new rows.

这告诉SQL Server验证对新行的约束。计数器示例将与NOCHECK一起使用,以暂时禁用新行的验证检查。

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

ALTER TABLE (Transact-SQL)(检查|和NOCHECK)

#1


3  

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.

检查失败会使约束不受信任,查询optimiser不能使用它们。

#2


1  

That tells SQL Server to validate the constraint against new rows. The counter example would be to use WITH NOCHECK to temporarily disable validation checks for new rows.

这告诉SQL Server验证对新行的约束。计数器示例将与NOCHECK一起使用,以暂时禁用新行的验证检查。

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

ALTER TABLE (Transact-SQL)(检查|和NOCHECK)