博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
oracle+drop多个,如何一次刪除多個約束(Oracle,SQL)
阅读量:6999 次
发布时间:2019-06-27

本文共 1467 字,大约阅读时间需要 4 分钟。

I'm changing constraints in my database and I need to drop some of them. I know that for a single constraint, the command is following:

我正在更改數據庫中的約束,我需要刪除其中一些約束。我知道對於單個約束,命令如下:

ALTER TABLE tblApplication DROP CONSTRAINT constraint1_name;

However, when I try

但是,當我嘗試

ALTER TABLE tblApplication DROP (

CONSTRAINT constraint1_name,

CONSTRAINT constraint2_name

);

it doesn't work and I need to do:

它不起作用,我需要這樣做:

ALTER TABLE tblApplication DROP CONSTRAINT constraint1_name;

ALTER TABLE tblApplication DROP CONSTRAINT constraint2_name;

Is there a way to remove more than one constraint in a single command? I'd like to avoid repeating ALTER TABLE tblApplication, just like with the ADD command:

有沒有辦法在單個命令中刪除多個約束?我想避免重復ALTER TABLE tblApplication,就像使用ADD命令一樣:

ALTER TABLE tblApplication

ADD {

CONSTRAINT contraint1_name FOREIGN KEY ... ENABLE,

CONSTRAINT contraint2_name FOREIGN KEY ... ENABLE,

};

2 个解决方案

#1

21

Yes you can. You just need to repeat 'drop constraint' per constraint. e.g.

是的你可以。您只需要為每個約束重復'drop constraint'。例如

alter table t1

drop constraint fk1

drop constraint fk2

/

Edit: I tested this against Oracle 11, and it worked fine. Don't know about older versions.

編輯:我對Oracle 11進行了測試,它運行良好。不知道舊版本。

#2

0

There is an alternative form to drop constraints related to a column in a table, also dropping the column with CASCADE:

有一種替代形式可以刪除與表中列相關的約束,同時使用CASCADE刪除列:

ALTER TABLE table1 DROP (columnName) CASCADE CONSTRAINTS;

It is tested on Oracle 11g

它在Oracle 11g上進行了測試

转载地址:http://ucevl.baihongyu.com/

你可能感兴趣的文章
MySQL8.0 新特性:Partial Update of LOB Column
查看>>
HTTP的历史
查看>>
对称加密、非对称加密、RSA(总结)
查看>>
Java高阶编程——RxBus 开源,基于 RxJava 的 event bus
查看>>
阿里云安全管家使用教程
查看>>
学习jQueryUI
查看>>
设计模式入门
查看>>
【函数式 Swift】可选值
查看>>
对使用Redux和Redux-saga管理状态的思考
查看>>
vscode中执行gulp的task
查看>>
intelli idea mac 的安装与配置
查看>>
说说如何使用 Tomcat 搭建文件服务器
查看>>
Vitalik探讨改进以太坊Casper CBC协议
查看>>
猎头最爱问的java面试题附答案(三)
查看>>
说说你生活中高颜值的程序员?
查看>>
从科学记数法到浮点数标准IEEE 754
查看>>
Netty杂记1—BIO网络编程
查看>>
Vue: Binding与Watcher
查看>>
Swift泛型定义 同时限定T的类(class)和多协议(protocol)
查看>>
从闭包函数的变量自增的角度 - 解析js垃圾回收机制
查看>>