Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> help: delete the duplecated records
I have a table with about 10,000 duplecated records. When I tried to use rowid to delete them, it takes a long long time to finish, and I have to cancel the query. The some body send me a procedure as follows,
Here's one I sometimes use when large number of dupes is involved -- it uses a small rollback.
Assuming table 'my_table' with field 'my_field' where 'my_field' is duped and cannot be used as the primary key:
Create a table containing (only) the distinct 'my_fields' which are duped:
create table dupes as
select my_field from my_table
group by my_field
having count(*) > 1
/
Then delete rows from 'my_table' that are duped using the strategy of keeping the first of a duped set of rows.
create or replace procedure de_dupe_my_table as
--
but it delete all the duplecated records instead of keeping the first one, could somebody help me out?
Thank you very much. Received on Mon Oct 16 2000 - 08:17:03 CDT