Need to delete duplicate records from table
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Need to delete duplicate records from table Expand / Collapse
Author
Message
Posted 2/20/2007 2:34:22 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 6/18/2007 5:02:00 PM
Posts: 18, Visits: 1
Hi,

I have many duplicate records in a table. Need to remove or delete these duplicate records from table. So that only one unique record exists.

Thanks,
rlaskar
Post #6634
Posted 2/20/2007 9:23:37 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 6/30/2008 3:00:56 AM
Posts: 22, Visits: 5
Hi Laskar

Here is the SQL to delete duplicate records,

DELETE FROM TABLE_NAME A
WHERE ROWID <>
(
SELECT MAX(ROWID) or MIN(ROWID) FROM TABLE_NAME B WHERE A.COLUMN_NAME = B.COLUMN_NAME
);

Stration


-:-
Post #6637
Posted 2/21/2007 12:01:54 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: PAC and SFT Members
Last Login: Yesterday @ 3:21:12 AM
Posts: 280, Visits: 310
Applications cannot reference internal ROWID directly in current releases. (In some releases it may be possible to enable this deprecated functionality for backward compatibility, but since the option will presumably be removed in a future release you should not design around it.)

Your supported options are: INSERT into another table (either using GROUP BY or Teradata's SET table functionality to remove duplicates), or do a multi-step process: Identify and "save" one copy of each set of duplicates (e.g. INSERT SELECT with GROUP BY ... HAVING COUNT(*) > 1), DELETE all copies of the duplicate rows, re-INSERT the saved single copies.

Post #6639
Posted 2/21/2007 2:23:35 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 6/25/2008 12:53:07 PM
Posts: 118, Visits: 60
Use fastexport 1st to select the rows and then create a flat file of records from the table. And then use fastload to load the records back into the table. Fastload does not load the duplicate records. Your task of eliminating the duplicate rows will be achieved.

Regards
Ramakrishna_Vedantam
Post #6640
Posted 2/21/2007 7:50:29 PM
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: 6/25/2008 7:48:49 PM
Posts: 60, Visits: 67

You can use an insert select statement:

insert into t1 select distinct * from t2;

where t1 is a set table and t2 is the multiset table with the duplicate rows you want to eliminate. Both tables have the same column definitions.

Post #6661
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 1 ( 1 guest, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 2:58am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 7 queries. Compression Disabled.