oracle 查看删除重复数据

1、查询重复数据
select * from 表名 where 重复字段(一般为主键)in (select 重复字段 from 表名 group by 重复字段 having count(WF_OID)>1)


Select 重复字段,Count(*) From表名 Group By 重复字段 Having Count(*) > 1

2、删除重复数据
DELETE from 表名 WHERE (id) IN ( SELECT 重复字段 FROM 表名 GROUP BY 重复字段HAVING COUNT(重复字段) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM 表名GROUP BY 重复字段 HAVING COUNT(*) > 1);

3、多条件重复数据

select 字段1,字段2 from 表名 a where (a.字段1,a.字段2) in
(select 字段1,字段2 from 表名 group by 字段1,字段2 having count(*) > 1)
and rowid not in (select min(rowid) from 表名 group by 字段1,字段2 having count(*)>1)

delete from 表名 a where (a.字段1,a.字段2) in
(select 字段1,字段2 from ITSM_CFG_GROUP_USER group by 字段1,字段2 having count(*) > 1)
and rowid not in (select min(rowid) from 表名 group by 字段1,字段2 having count(*)>1)

注意:rowid 不用改

注意:脑子里记录一下删除前与删除后的数据数

原文地址:https://www.cnblogs.com/xiaoyu1994/p/8277284.html