Delete duplicate records from table

Summary 

To select all duplicate records from a table and delete them use the queries below:

SELECT * FROM table_with_duplicates WHERE ROWID NOT IN
(SELECT MIN (ROWID) FROM table_with_duplicates 
GROUP BY col1, col2, col3);

DELETE FROM table_with_duplicates WHERE ROWID NOT IN
(SELECT MIN (ROWID) FROM table_with_duplicates  
GROUP BY col1, col2, col3);

Comments

Popular posts from this blog

Change Protection Mode for Active Dataguard (11GR2)

Reboot Exadata Machine

STEPS TO troubleshoot long running concurrent request in R12.2.x