CREATE TABLE movie (
ID int PRIMARY KEY,
name varchar2(50) NOT NULL
);
CREATE TABLE length (
ID int PRIMARY KEY REFERENCES movie(ID) ON DELETE CASCADE,
length int NOT NULL
);
於是,我就從兩個刪除值:
delete from movie where ID=1;
,但得到的錯誤:
"attempted to delete a parent key value that had a foreign dependency."
爲什麼如果我使用ON DELETE CASCADE?
實際使用哪些DBMS? varchar2不是有效的sql server數據類型。這是Oracle嗎? –
對不起,是的,這是Oracle(SQL Developer) – Linz
'CASCADE'選項在另一個方向上工作。如果從長度刪除,它將刪除子表上的引用行。檢查關係定義。 – Alfabravo