Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Duplicate rows

Re: Duplicate rows

From: Stephane Faroult <sfaroult_at_oriole.com>
Date: Wed, 06 Feb 2002 10:26:26 -0800
Message-ID: <F001.004076EA.20020206082332@fatcity.com>

Alexander Ordonez wrote:
>
> Hi gurus,
> I need detect and delete duplicate rows in any table, somebody helpme
> thanks!!!
>
> @lex
> ------------------------------------------------------------
> Lic. Alexander Ordóñez Arroyo
> Caja Costarricense del Seguro Social
> Soporte Técnico - División de Informática
> Telefono: 295-2004, San José, Costa Rica
> Aordonez_at_ccss.sa.cr Icq# 30173325
>
> ------------------------------------------------------------

Check the EXCEPTIONS clause of the ALTER TABLE ... ADD CONSTRAINT command. Create an EXCEPTIONS table, create a unique constraint on the columns which *should* be unique, then proceed as follows : create table nodup
as select distinct * from <my_table>

   where rowid in (select row_id from exceptions

                   where table_name = upper('<my_table>');
(I dislike distinct but sometimes ... :-)) delete <my_table>
where rowid in (select row_id from exceptions
                where table_name = upper('<my_table>');
insert into <my_table>
select * from nodup;
drop table nodup;
truncate table exceptions;

and go on with the next table. Write a script which takes a parameter for all this part, no need to retype it each time.

-- 
Regards,

Stephane Faroult
Oriole Ltd
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Stephane Faroult
  INET: sfaroult_at_oriole.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Feb 06 2002 - 12:26:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US