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
>   [EMAIL PROTECTED]        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: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).

Reply via email to