Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Duplicate rows
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 table_name = upper('<my_table>');insert into <my_table>
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
![]() |
![]() |