oracle单表重复数据处理

1、查询表中多余的重复记录,重复记录是根据peopleId来判断
select * from people where
    where peopleId in (
select  peopleId from people group by peopleId having count(peopleId)
        )

2、删除表中多余的重复记录,复记录是根据peopleId来判断,只留rowid最小的记录
delete from people
    where  peopleId in (
select  peopleId from people group by peopleId having count(peopleId)>1
        )
and not in (
select  min(rowid) from people group by peopleId having count(peopleId)>1
    )


3、查询表中多余的重复记录(多个字段)
select * from  people a where (a.peopleId,a.seq) in (
select  peopleId,seq from people group by peopleId,seq having count(*)>1
    )


你可能感兴趣的:(Oracle相关)