Delete Duplicate Rows Oracle

Check for Duplicate Row using Group By function

This script deletes each row in the group after the first row.

DELETE FROM our_table
WHERE rowid not in
(SELECT MIN(rowid)
FROM our_table
GROUP BY column1, column2, column3… ;

delete FROM TXN_TABLE
WHERE rowid not in
(SELECT MIN(rowid)
FROM TXN_TABLE
GROUP BY TRNX_UID);

select COUNT(*) FROM TXN_TABLE
WHERE rowid not in
(SELECT MIN(rowid)
FROM TXN_TABLE
GROUP BY TRNX_UID);

Leave a Reply