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

Reboot Exadata Machine

ORA-01565: error in identifying file '?/dbs/spfile@.ora'

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