您的位置:首页 > 数据库 > Oracle

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

2016-12-19 22:47 267 查看
例子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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: