Re: remove duplicates

  • From: Anupam Pandey <my.oralce@xxxxxxxxx>
  • To: oracle Freelists <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 30 Aug 2010 16:57:30 +0530

Hi Listers ,
                Regarding deleting duplicate ..

We have a big DW table and we are loading data in from different files . Now
if some of the files have duplicate record then we dont want to abort the
whole loading operation instead we want to capture the duplicate records in
different table and normal loading to proceed successfully eleminating the
duplicates.

So all duplicates will be in second table but data will get loaded in first
table without duplicate .

I tried the exception table approach but it did not work .Main table
contains the duplicates and unique key will not be enabled and duplicate row
will be
put in exception table .

Is there any feature available in oracle to support this requirement or I
will have to build a custom process for this .


create table test_object
as
select *
from user_objects;

ALTER TABLE test_object
add CONSTRAINT idx_id UNIQUE (object_id);

alter table test_object disable constraint idx_id;

create table exceptions(row_id rowid,
                    owner varchar2(30),
                    table_name varchar2(30),
                constraint varchar2(30));


insert into test_object
 select *
from test_object
where rownum < 2


alter table test_object enable constraint IDX_ID exceptions into exceptions;

select *
from exceptions;

Thanks And Regards,
   Anupam Pandey

On Thu, Jul 29, 2010 at 1:37 AM, Michael Dinh <mdinh@xxxxxxxxx> wrote:

>  Take a look at this website for deleting duplicates using analytics.
>
>
>
> http://viralpatel.net/blogs/2010/06/deleting-duplicate-rows-in-oracle.html
>
>
>
> Michael Dinh : XIFIN : 858.436.2929
>
>
>
> NOTICE OF CONFIDENTIALITY - This material is intended for the use of the
> individual or entity to which it is addressed, and may contain information
> that is privileged, confidential and exempt from disclosure under applicable
> laws.  BE FURTHER ADVISED THAT THIS EMAIL MAY CONTAIN PROTECTED HEALTH
> INFORMATION (PHI). BY ACCEPTING THIS MESSAGE, YOU ACKNOWLEDGE THE FOREGOING,
> AND AGREE AS FOLLOWS: YOU AGREE TO NOT DISCLOSE TO ANY THIRD PARTY ANY PHI
> CONTAINED HEREIN, EXCEPT AS EXPRESSLY PERMITTED AND ONLY TO THE EXTENT
> NECESSARY TO PERFORM YOUR OBLIGATIONS RELATING TO THE RECEIPT OF THIS
> MESSAGE.  If the reader of this email (and attachments) is not the intended
> recipient, you are hereby notified that any dissemination, distribution or
> copying of this communication is strictly prohibited. Please notify the
> sender of the error and delete the e-mail you received. Thank you.
>
> *From:* oracle-l-bounce@xxxxxxxxxxxxx [mailto:
> oracle-l-bounce@xxxxxxxxxxxxx] *On Behalf Of *Barbara Baker
> *Sent:* Wednesday, July 28, 2010 10:14 AM
> *To:* ORACLE-L
> *Subject:* remove duplicates
>
>
>
> oracle 9.2.0.7 on linux
> I have some duplicated records in a table (woe_fact_barb)
> I cannot come up with the sql to remove these.  Can anyone help?
> The only way to identify the duplicate is that there are 2 records with the
> same WO_SID.
>
>    WOE_SID     WO_SID   INVC_AMT
> ---------- ---------- ----------
>    1079559  177694790     7898.1
>    1080085  177694790     7898.1
>    1079589  177694810   24026.19
>    1079663  177694810   24026.19
>    1079567  177694858   17088.35
>    1080135  177694858   17088.35
>
> I've tried various combinations of sql sorta like this:
>
> sql>delete from woe_fact_barb
>   2  (select min(woe_sid)
>   3  from woe_fact_barb )
>   4  where wo_sid=177694790
>   5  /
>
> Nothing I've tried is close.
> thanks for any help!
> Barb
>

Other related posts: