一张person表,有ID和name的两个字段,ID是唯一的不允许重复,ID相同则认为是重复的记录。
select ID from group by ID having count(*) > 1
查找表中多余的重复记录,重复记录是根据单个字段(ID)来判断
select * from 表 where ID in (select ID from 表 group byID having count(ID) > 1)
删除表中多余的重复记录,重复记录是根据单个字段(ID)来判断,只留有rowID最小的记录
DELETE from 表 WHERE (ID) IN ( SELECT ID FROM 表 GROUP BY ID HAVING COUNT(ID) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM 表 GROUP BY ID HAVING COUNT(*) >1);
查找表中多余的重复记录(多个字段)
select
* from 表 a where (a.ID,a.seq) in(select ID,seq from 表 group by ID,seq having
count(*) > 1)
删除表中多余的重复记录(多个字段),只留有rowID最小的记录
delete
from 表 a where (a.ID,a.seq) in (select ID,seq having
count() > 1) and rowID not in (select min(rowID) from 表 group by ID,seq
having count()>1)
查找表中多余的重复记录(多个字段),不包含rowID最小的记录
select
* from 表 a where (a.ID,seq
having count()>1)
以上是内存溢出为你收集整理的oracle里面查询重复数据的方法全部内容,希望文章能够帮你解决oracle里面查询重复数据的方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)