Oracle 怎么删除重复数据
生活随笔
收集整理的這篇文章主要介紹了
Oracle 怎么删除重复数据
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、根據rowid來查詢重復數據
select * from table1 a where rowid !=(select max(rowid) from table1 b where a.name1=b.name1 )2、根據rowid來刪除重復數據
delete from table1 a where rowid !=(select max(rowid) from table1 b where a.name1=b.name1 )3、根據group by來查詢重復數據
select * from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)4、刪除表中多余的重復記錄,重復記錄是根據單個字段(Id)來判斷,只留有rowid最小的記錄
delete from people where Id in (select Id from people group by Id having count(Id) > 1) and rowid not in (select min(rowid) from people group by Id having count(Id)>1)5、查找表中多余的重復記錄(多個字段),不包含rowid最小的記錄
select * from 表 a where (a.Id,a.seq) in (select Id,seq from 表 group by Id,seq having count(*) > 1) and rowid not in (select min(rowid) from 表 group by Id,seq having count(*)>1)總結
以上是生活随笔為你收集整理的Oracle 怎么删除重复数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vc++类型转换
- 下一篇: linux命令——crontab的使用方