Skip site navigation (1) Skip section navigation (2)

Re: duplicate records

From: Selena Deckelmann <selena(at)chrisking(dot)com>
To: Thomas J Keller <kellert(at)ohsu(dot)edu>, pdxpug(at)postgresql(dot)org
Subject: Re: duplicate records
Date: 2006-10-18 21:43:17
Message-ID: 47ed9e2ed59c142a86246f08842edc97@chrisking.com (view raw or flat)
Thread:
Lists: pdxpug
On Oct 18, 2006, at 2:23 PM, Thomas J Keller wrote:

> Greetings,
> Is it appropriate to ask an operational question - not necessarily 
> unique to postgresql?
>
> I inserted a few hundred records into a new database table and 
> discovered that several where duplicates.
> How does one select these (so they can be deleted)?

You could create a temporary table, SELECT DISTINCT from your problem 
table, drop the original table, and then move your temp table data into 
the original table.

If your primary key has duplicates, you'll need to make your temporary 
table a little different than your original table.

-selena


In response to

Responses

pdxpug by date

Next:From: Thomas J KellerDate: 2006-10-18 22:16:23
Subject: Re: duplicate records
Previous:From: David E. WheelerDate: 2006-10-18 21:39:58
Subject: Re: duplicate records

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group