使用oracle删除表中重复记录
Posted 清-华-园
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用oracle删除表中重复记录相关的知识,希望对你有一定的参考价值。
(1)使用用rowid方法
查询重复数据:select * from person a where rowid !=(select max(rowid) from person b where a.cardid=b.cardid and a.pname=b.pname);
删除重复数据:delete from person a where rowid !=(select max(rowid) from person b where a.cardid=b.cardid and a.pname=b.pname);
(2)使用group by方法
查询重复数据:select * from person where cardid in (select cardid from person group by cardid having count(cardid)>1);
删除重复数据:delete from person where cardid in (select cardid from person group by cardid having count(cardid)>1) and rowid not in (select min(rowid) from person group by cardid having count(cardid)>1);
以上是关于使用oracle删除表中重复记录的主要内容,如果未能解决你的问题,请参考以下文章