Delete duplicate rows in Oracle
Delete duplicate rows in Oracle
Topic Introduction: In this tutorial, we will show how to delete duplicate rows in Oracle.
Method #1
DELETE FROM employeesWHERE ROWID NOT IN ( SELECT MIN (ROWID)FROM employeesGROUP BY LAST_NAME);
Method #2
DELETE FROM employeesWHERE ROWID IN(SELECT ridFROM (SELECT ROWIDrid,ROW_NUMBER ()OVER (PARTITION BY LAST_NAME ORDER BY ROWID)rnFROM employees)WHERE rn <> 1);
Method #3
DELETE FROM employees aWHERE a.ROWID > ANY (SELECT b.ROWIDFROM employees bWHERE a.LAST_NAME = b.LAST_NAME);
No comments