一、方法原理:
1、Oracle中,每一条记录都有一个rowid,rowid在整个数据库中是唯一的, rowid确定了每条记录是在ORACLE中的哪一个数据文件、块、行上。
2、在重复的记录中,可能所有列的内容都相同,但rowid不会相同,所以只要确定出重复记录中那些具有最大rowid的就可以了,其余全部删除。
二、实现方法:
1、查询重复记录
select rowid,haptime,numberplate,reason from peccancy
--delete from peccancy6 peccancy6
where peccancy.rowid !=
(
select max(rowid) from peccancy b
where peccancy.haptime = b.haptime and
peccancy.numberplate = b.numberplate and
peccancy.reason = b.reason
)
2、删除重复记录
delete from peccancy peccancy
where peccancy.rowid !=
(
select max(rowid) from peccancy b
where peccancy.haptime = b.haptime and
peccancy.numberplate = b.numberplate and
peccancy.reason = b.reason
)
358




被折叠的 条评论
为什么被折叠?



