Re: Deleting duplicate records

From: Dmitry Tkach <dmitry(at)openratings(dot)com>
To: Bob Powell <Bob(at)hotchkiss(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Deleting duplicate records
Date: 2003-06-02 14:39:06
Message-ID: 3EDB618A.1080409@openratings.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bob Powell wrote:

>Hello everyone:
>
>Can someone tell me if there is a way to delete duplicate records from a table in Postgres.
>
>I once used a database management system that had a "Delete Duplicates" which would check every field in the row and if they all matched would delete the row. You could also designate the fields you wanted the command to use to check for dups. Very nice feature. Maybe something for the TODO list?
>
>
As generally as you state the problem, something like this comes to mind:

select distinct * into temp unique_rows from table_to_cleanup;
truncate table_to_cleanup;
insert into table_to_cleanup select * from unique_rows;

I hope, it helps...

Dima

>Bob Powell
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/docs/faqs/FAQ.html
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message culley harrelson 2003-06-02 14:50:40 installing contrib/tsearch with a FreeBSD Port
Previous Message culley harrelson 2003-06-02 14:36:54 installing contrib/tsearch with a FreeBSD Port