9/08/2017

Oracle sql delete duplicate records from table

In the case when you need to identify duplicate rows and remove them from the table - use the SQL query below.


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

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

No comments:

Post a Comment

Popular Posts