Posted by: songbard | October 23, 2008

PL/SQL : Duplicate elimination from a table.

Supposing a table having a hostname column are peppered with duplicate values in the same field.

To eliminate duplicate and keep only one of a kind….

declare

cursor c1 is

select distinct hostname from <table>;

begin

for record in c1

loop

delete from <table> where hostname = record.hostname

and

rownum != (select count(*) from <table> where hostname = record.hostname);

end loop;

end;

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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

Categories

%d bloggers like this: