Re: What does count(*) count?

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: "Pgsql-General(at)Postgresql(dot)Org (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: What does count(*) count?
Date: 2003-12-31 16:46:30
Message-ID: 20031231174630.F941@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> In the database table the records have duplicated and I've two rows for
> every primary key - with different OIDs.
> Is there any safe method to get rid of only one of each duplicated row?

select distinct on (oid) * from your_table into working_table

check working_table

truncate your_table

select from working_table into your_table
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-12-31 16:46:34 Re: Bug and/or feature? Complex data types in tables...
Previous Message Lee Harr 2003-12-31 16:37:57 finding my schema (for sequences)