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);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s