Oracle Delete inner的方式,级联删除子表的数据方式。

例子1:

delete from table1 a where exists (select 1 from table2 b where a.id=b.id)

例子2:

rebatepolicy表是主表,rebatepolicyitems是从表,从表有主表的主键,现在对于主表一些条件的数据的对应子表要求删除。

如下方式:

delete from rebatepolicyitems rs where exists
(
      select 1
      from rebatepolicy r  where rs.rebateguid=r.rebateguid
      and to_char(r.createdate,'yyyyMMdd')='20161219' and r.creator='名字' 
)

 

delete from table1 a where exists (select 1 from table2 b where a.id=b.id)
posted @ 2016-12-19 22:47  美好的明天  阅读(662)  评论(0编辑  收藏  举报