2014-04-07 91 views
-2
DELETE tbemp.emp_id, 
     tbadd.emp_id 
FROM TBEMPLOYEE tbemp 
JOIN TBADDRESS tbadd ON (tbemp.emp_id=tbadd.emp_id) 

的Oracle 11g不編譯刪除數據

回答

1

這delete語句不是甲骨文有效。還有其他刪除語句,其中一個可能是

DELETE FROM TBEMPLOYEE tbemp 
WHERE EXISTS (select 'x' 
       from TBADDRESS 
       where tbemp.emp_id=tbadd.emp_id); 
0

您無法直接使用連接從多個表中刪除。

但是,您可以使用ON DELETE CASCADE強制執行外鍵約束。

ALTER TABLE tbaddress ADD CONSTRAINT fk_emp FOREIGN KEY (emp_id) REFERENCES tbemployee (emp_id) ON DELETE CASCADE; 

DELETE FROM tbemployee; -- This also deletes referencing keys from tbaddress