SQL,删除级联和更新级联
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22881022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL, On delete cascade and on update cascade
提问by Dimitar Spasovski
I am new to SQL and I encountered a weird problem. So I have two tables OFFERS and SUPPLIER. Here is the Supplier table.
我是 SQL 新手,遇到了一个奇怪的问题。所以我有两张桌子 OFFERS 和 SUPPLIER。这是供应商表。
CREATE TABLE "SUPPLIER"
( "S#" NUMBER,
"NAME" VARCHAR2(50),
"CITY" VARCHAR2(50),
PRIMARY KEY ("S#") ENABLE
)
And here is the OFFERS table.
这是 OFFERS 表。
CREATE TABLE "OFFERS"
( "P#" NUMBER,
"S#" NUMBER,
"V#" NUMBER,
"PR#" NUMBER,
CONSTRAINT "PK_OFFERS" PRIMARY KEY ("P#") ENABLE
)
So now, when I try to add a Foreign key constraint to the offers table like this
所以现在,当我尝试像这样向优惠表添加外键约束时
ALTER TABLE OFFERS
ADD CONSTRAINT FK_SUPPLIERS FOREIGN KEY(S#)
REFERENCES SUPPLIER (S#)
ON DELETE CASCADE
ON UPDATE CASCADE
I get an error saying : "ORA-01735: invalid ALTER TABLE option". If I remove the last line, which is "ON UPDATE CASCADE" this works perfectly fine. So, what am I doing wrong? I've seen a lot of examples like this on the internet, that are supposed to work, so I am kinda confused. I am working on apex.oracle.com if that makes any difference.
我收到一条错误消息:“ORA-01735:无效的 ALTER TABLE 选项”。如果我删除最后一行,即“ON UPDATE CASCADE”,则效果很好。那么,我做错了什么?我在互联网上看到很多这样的例子,应该可以工作,所以我有点困惑。如果这有什么不同,我正在 apex.oracle.com 上工作。
回答by evenro
There is no "on update cascade" in Oracle as far as I know (even in current versions):
据我所知,Oracle 中没有“更新级联”(即使在当前版本中):
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5773459616034
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5773459616034