How To Remove Duplicate Rows From A Table In Oracle (PlSql)

We can easily remove duplicate rows from a table in Oracle. There are a lot of ways with SQL.

We can use this easy method:

DELETE FROM TABLE_NAME
WHERE ROWID NOT IN ( SELECT MIN (ROWID)
FROM TABLE_NAME
GROUP BY COL1,
COL2,
COL3,
COL4);

Let’s make an example of a scenario.

Sample Table (Before Delete)
DELETE FROM CUSTOMERS
WHERE ROWID NOT IN ( SELECT MIN (ROWID)
FROM CUSTOMERS
GROUP BY CUSTOMER_NUMBER,
NAME,
SURNAME,
PHONE_NUMBER,
E_MAIL,
COUNTRY,
CITY);
Sample Table (After Delete)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store