Oracle 删除重复数据的几种方法
转载去重
第一种:distinct
create table tmp_t3 as select distinct * from t3;
drop table t3;
alter table tmp_t2 rename to t3;
-- 第二种,用rowid
delete from t2
where rowid <>( select min(rowid)
from t2 b
where b.c1 = t2.c1
and b.c2 = t2.c2 )
---第三种, 用rowid + group by 的方法
delete from T2
where rowid not in (select min(rowid)
from t2 group by c1,c2 );
delete from t2
where not exists (select 1 from (select min(rowid) rid from t2 group by c1,c2) b where b.rid=t2.rowid)
---第四种, 用分析函数
delete from t2 where rowid in
(select b.rd from
(select rowid rd,row_number() over(partition by c1,c2 order by c1) rn
from t2) b
where b.rn > 1);
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
postgresql 常用的删除重复数据方法
最高效方法...
postgresql 快速去重 删除 高效 数据