Delete Duplicate Rows From A Table

Deleting duplicate emp_id s from the EMP Table.

1) DELETE FROM EMP E1
WHERE ROWID >(SELECT min(ROWID)
FROM EMP E2
WHERE E1.EMP_ID = E2.EMP_ID);

2) DELETE FROM EMP E1
WHERE E1.EMP_ID IN (SELECT E2.EMP_ID
FROM EMP E2
WHERE E1.EMP_ID = E2.EMP_ID
AND E1.ROWID > E2.ROWID);

No comments:

Post a Comment