Oracle DBA Tips and Techniques

By Arjun Raja

DELETE DUPLICATES IN TABLE

Posted by Arjun Raja on September 9, 2009

DELETE DUPLICATES IN A TABLE –

EX – TABLE TEST

SQL> desc test;

COL_1 NUMBER(10)
COL_2 DATE

SQL>

select count(*) from test WHERE ROWID IN
(select rowid from test
minus
select max(rowid) from test
group by
col_1,col_2);

delete from test WHERE ROWID IN
(select rowid from test
minus
select max(rowid) from test
group by
col_1,col_2);

x——–x———-x———x———-x

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

 
%d bloggers like this: