oracle查询表内的重复数据,并删除重复数据


---查询重复数据:

select *
     from user_tab u
      where u.aa003 in (select u.aa003 
        from user_tab u
           group by u.aa003   having count(*) > 1)

----删除重复数据:
delete from user_tab 
  where aa003 in (select aa003 from 
    user_tab group by aa003 having count(aa003) > 1) 
      and rowid not in (select min(rowid) from 
        user_tab group by aa003 having count(aa003 )>1) 


 

你可能感兴趣的:(oracle)