Re: DELETE DUPLICATES

From: Richard Sullivan <rsulliva_at_.oracle.com>
Date: Thu, 17 Jun 1993 15:02:23 GMT
Message-ID: <1993Jun17.150223.25240_at_oracle.us.oracle.com>


In article <1vihg4$2mt_at_sun.Panix.Com> eblinder_at_panix.com (Eva Blinder) writes:
>In <1va9pm$7mc_at_erau.db.erau.edu> mellott_at_db.erau.edu (David Michael Mellott) writes:
>
>>does anyone have a simple script to delete duplicates
>>from a table
>>I thank you in advance\mike
>>.
>
>delete from mytab
>where rowid in (select min(rowid) from mytab
> group by primary_key
> having count(*) > 1);
>
>You'll have to run this more than once if you have tripicates,
>quadruplicates, etc.
>

How about >> delete from mytab where rowid not in (select max(rowid)

                                 from mytab group by primary_key);
This would only need to be run once (and if there are any of you still on v5 :-( this will not work unless you run a select for update prior to the delete....

Opinions are my own, as usual.

"You can't push on a rope..."

rsulliva_at_us.oracle.com Received on Thu Jun 17 1993 - 17:02:23 CEST

Original text of this message