日期:2014-05-16  浏览次数:20463 次

查找重复记录和删除(转载)
create table p (id number(20) not null primary key,name varchar2(20),
address varchar2(20));

查找重复:
1 select name,address from p group by name,address having count(*)>1
2 select distinct name,address from p
3 select pp.*,id from p pp where id in (select max(id) from p t where pp.name=t.name and pp.address=t.address)

删除重复:
适用于有大量重复记录
1  delete p where rowid not in
            (select min(rowid) from p group by name,address);
适用于有少量重复记录的情况
2 delete from p a where rowid <(select max(rowid)
            from p where name=a.name and address=a.address );