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.
I use the following method:

1
2
3
4
 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):

beforeRemoveDuplicateRows

Sample Query:

1
2
3
4
 DELETE FROM xx_employee
      WHERE ROWID NOT IN (  SELECT MIN (ROWID)
                              FROM xx_employee
                          GROUP BY employee_number, first_name, last_name, sex, job);

Sample Table (After Delete):

afterRemoveDublicateRows