SQL, On delete cascade and on update cascade

一世执手 提交于 2019-12-02 05:31:48

问题


I am new to SQL and I encountered a weird problem. So I have two tables OFFERS and SUPPLIER. Here is the Supplier table.

CREATE TABLE  "SUPPLIER" 
   (    "S#" NUMBER, 
    "NAME" VARCHAR2(50),  
    "CITY" VARCHAR2(50), 
     PRIMARY KEY ("S#") ENABLE
   )

And here is the OFFERS table.

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.


回答1:


There is no "on update cascade" in Oracle as far as I know (even in current versions):

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5773459616034



来源:https://stackoverflow.com/questions/22881022/sql-on-delete-cascade-and-on-update-cascade

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!