Anupam, You say that your loading from files, which I think probably means your loading via sql*loader of some other similar application. If that is so then keeping the constraint enabled will cause that application to see the error and possibly handle it in a different manner. Now if the application, like sql*loader can't handle that and load into a different table, then inserting through a load view with an instead of trigger may be the best option since the instead of trigger can have an exception handler for when the PK is violated moving the data to the exceptions table. Using the "alter constraint ... exceptions into" syntax does not move any rows, it simply loads the rowid's of the errant data into the exceptions table & leaves the constraint disabled. Dick Goulet Senior Oracle DBA/NA Team Lead PAREXEL International ________________________________ From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Anupam Pandey Sent: Monday, August 30, 2010 7:28 AM To: oracle Freelists Subject: Re: remove duplicates 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.ht ml 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