About Me

Translate

Tuesday, April 26, 2016

How to find and delete duplicate records in Oracle Database

There are many ways you can do this - Below is one simple way to do it

select column_name, count(column_name)
from table
group by column_name
having count (column_name) > 1;

How to delete duplicate records in Oracle Database

delete from
   table_name a
where
   a.rowid >
   any (select b.rowid
   from
      table_name b
   where
      a.col1 = b.col1
   and
      a.col2 = b.col2
   );

No comments:

Post a Comment