级联删除查询

Nit*_*its 5 sql oracle

我有三张桌子.产品,公司,员工

Product表的ProductId是Company的foregin密钥,Company表的CompanyId是Employee的foregin密钥

因此,在从Product表中删除ProductId时,应删除其他表中的所有相关记录.但我无法触摸架构(不能使用alter table).在这种情况下我应该如何编写查询..

Eri*_*ler 9

如果无法添加传播删除的约束,则必须自己编写所有必需的删除:

delete employee where companyid in (select companyid from company c where productid = xxx);
delete company where productid=xxx;
delete product where productid=xxx;
Run Code Online (Sandbox Code Playgroud)