发布网友 发布时间:2022-04-08 10:01
共2个回答
懂视网 时间:2022-04-08 14:23
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断 select * from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录 delete from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1) and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)
3、查找表中多余的重复记录(多个字段) select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录 delete from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录 select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
关键看什么字段相同算重复,如果是arrearmain_id、reladdr、addrsourcetype的话,那这样写是最高效的,因为用了rowid: delete from cncc_customeraddr_tab t where t.rowid > (select min(x.rowid) from cncc_customeraddr_tab x where x.arrearmain_id = t.arrearmain_id and x.reladdr = t.reladdr and x.addrsourcetype = t.addrsourcetype) and t.addrsourcetype = ‘1300000001‘
转自:http://www.cnblogs.com/wjlstation/archive/2012/06/20/2555832.html
oracle删除同一张表的重复记录
标签:
热心网友 时间:2022-04-08 11:31
---查找重复数据