从两个数据库中删除重复的记录

时间:2009-08-27 01:17:49

标签: sql oracle sql-delete

我设法识别来自两个不同数据库的重复记录:

select * from 
    taskperformance a,  taskperformance@dm_prod b
where 
    a.activityin = b.activityin
    and a.completiondate = b.completiondate

如何从b删除重复记录?

我试过了:

delete taskperformance@dm_prod  where exist ( 
select * from 
    taskperformance a,  taskperformance@dm_prod b
where 
    a.activityin = b.activityin
    and a.completiondate = b.completiondate ) 

但它删除的内容超出了我的需要。

1 个答案:

答案 0 :(得分:2)

您不应该在子查询中重新引用b

delete taskperformance@dm_prod b
where exists (
    select * from taskperformance a
    where a.activityin = b.activityin 
    and a.completiondate = b.completiondate 
)