我是sql的新手...对于我的任务我正在尝试在级联上设置更新并在级联上删除。然而,它给我一个错误,说它错过了一个关键词
这是我的代码:
DROP TABLE BEACH;
DROP TABLE OCEANS;
CREATE TABLE OCEANS
(OceanTitle VARCHAR(18),
AverageDepth NUMBER(8),
PrecentOfSurface NUMBER(8),
CONSTRAINT OCEANS_OceanTitle_pk PRIMARY KEY (OceanTitle));
CREATE TABLE BEACH
(BeachTitle VARCHAR(18),
State VARCHAR(18),
CONSTRAINT BEACH_BeachTitle_pk PRIMARY KEY (BeachTitle),
CONSTRAINT BEACH_OceanTitle_fk FOREIGN KEY(OceanTitle) REFERENCES OCEANS(OceanTitle),
OceanTitle VARCHAR(18) REFERENCES OCEANS(OceanTitle) ON update CASCADE,
OceanTitle VARCHAR(18) REFERENCES OCEANS(OceanTitle) ON delete CASCADE
);
INSERT INTO OCEANS VALUES ('Pacific', 13740, 48);
INSERT INTO OCEANS VALUES ('Atlantic', 12254, 28);
INSERT INTO OCEANS VALUES ('Gulf', 5299, 1);
INSERT INTO BEACH VALUES ('Manele Bay', 'Hawaii', 'Pacific');
INSERT INTO BEACH VALUES ('Myrtle Beach', 'South Carolina', 'Atlantic');
INSERT INTO BEACH VALUES ('Nantucket', 'Massachusetts', 'Atlantic');
INSERT INTO BEACH VALUES ('Clearwater Beach', 'Florida', 'Gulf');
INSERT INTO BEACH VALUES ('Coronado', 'California', 'Pacific');
错误消息:
OceanTitle VARCHAR(18) REFERENCES OCEANS(OceanTitle) ON update CASCADE,
*
ERROR at line 6:
ORA-00905: missing keyword
答案 0 :(得分:0)
您的陈述中的问题是On Update Cascade
,这在Oracle中不可用。
删除后重新执行您的声明。
答案 1 :(得分:0)
正如之前的回答所述,Oracle中没有On Update Cascade
。
以下是一些解决方法:
http://www.dba-oracle.com/oracle_tips_cascade_update.htm
(tom kyte script)http://tkyte.blogspot.ro/2009/10/httpasktomoraclecomtkyteupdatecascade.html
受限制的约束 http://www.java2s.com/Tutorial/Oracle/0120__Table/DeferredConstraints.htm
希望这会有所帮助 - 祝你好运