donderdag 11 april 2013

Oracle: Remove duplicate rows

In Oracle, when there are duplicate rows in a table, use the following piece to remove them:

DELETE <TABLE> WHERE ROWID IN
(
SELECT min(ROWID)
FROM <TABLE>
GROUP BY COLUMN1, COLUMN2, ...
HAVING count(1) > 1
)
Use all the columns in the table in the "group by" clause to ensure that the rows are identical.

Geen opmerkingen:

Een reactie posten