SQL Server中的Oracle删除约束级联等效 [英] Oracle drop constraint cascade equivalent in Sql Server

查看:136
本文介绍了SQL Server中的Oracle删除约束级联等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Oracle中,要删除约束PK_SAI,我使用以下语法:

In Oracle, to drop the constraint PK_SAI I use the syntax:

ALTER TABLE "SAISIE" 
    DROP CONSTRAINT "PK_SAI" CASCADE;

在SQL Server中这等效于什么?

What is the equivalent of this in SQL Server?

推荐答案

您正在考虑与实际DELETE语句有关的FOREIGN KEY约束的CASCADE功能.

You are thinking of the CASCADE feature on FOREIGN KEY constraints, in relation to actual DELETE statements.

ALTER TABLE t2 add constraint FK_T2 foreign key(t_id) references t(id)
   ON DELETE CASCADE;

使用CASCADE删除约束不会删除任何行.

Dropping a constraint with CASCADE does not delete any rows.

如果您启用了ON DELETE CASCADE,则删除将删除行.

DELETE deletes rows, if you have enabled ON DELETE CASCADE.

删除约束只是删除约束(以及关联的索引和从属约束),而不是数据行.在SQL Server ALTER TABLE ...中,我不知道像在Oracle中那样有一个"CASCADE"选项.

Dropping the constraint simply drops the constraint (and associated indexes and dependent constraints), not data rows. In SQL Server ALTER TABLE ... I am not aware that there is a "CASCADE" option as in Oracle.

来自Oracle文档 http://docs.oracle .com/cd/B28359_01/server.111/b28286/statements_3001.htm#i2103845 用于ALTER TABLE语句:

From Oracle docs http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_3001.htm#i2103845 for the ALTER TABLE statement:

CASCADE如果您还希望删除所有其他依赖于丢弃的完整性约束的完整性约束,请指定CASCADE.

CASCADE Specify CASCADE if you want all other integrity constraints that depend on the dropped integrity constraint to be dropped as well.

这篇关于SQL Server中的Oracle删除约束级联等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆