DELETE tbemp.emp_id,
tbadd.emp_id
FROM TBEMPLOYEE tbemp
JOIN TBADDRESS tbadd ON (tbemp.emp_id=tbadd.emp_id)
Oracle 11g无法编译它
答案 0 :(得分:1)
此删除语句在Oracle中无效。还有其他删除声明,一个可能是
DELETE FROM TBEMPLOYEE tbemp
WHERE EXISTS (select 'x'
from TBADDRESS
where tbemp.emp_id=tbadd.emp_id);
答案 1 :(得分: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