码迷,mamicode.com
首页 > 数据库 > 详细

使用oracle删除表中重复记录

时间:2018-04-16 00:43:09      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:HERE   记录   strong   card   person   重复   nbsp   方法   str   

 (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删除表中重复记录

标签:HERE   记录   strong   card   person   重复   nbsp   方法   str   

原文地址:https://www.cnblogs.com/hongwei2085/p/8850300.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!