Deleting duplicate rows from Oracle Table

Tip Courtesy: Oracle Tips by Burleson Consulting (dba-oracle)

Removing duplicate rows from Oracle tables with SQL can be very tricky, and there are several techniques. This post shows some examples of using SQL to delete duplicate table rows using an SQL sub query to identify duplicate rows, manually specifying the join columns:

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
        );


For a script that does not uses ROWID concept, read this post.

Deleting/Listing duplicate records without ROWID

Comments

Popular posts from this blog

Reports Builder wont open in Windows 10 64bit - [SOLVED]

csv Data to Rows - SQL

Your session has expired - For Custom Apps after Oracle Apex Upgrade from 5 to 20