Re: remote duplicate rows

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: remote duplicate rows
Date: 2006-09-14 06:14:44
Message-ID: 20060914061444.GB1258@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Wed, dem 13.09.2006, um 15:46:58 -0700 mailte Junkone folgendes:
> hI
> i have a bad situation that i did not have primary key. so i have a
> table like this
> colname1 colname2
> 1 apple
> 1 apple
> 2 orange
> 2 orange
>
> It is a very large table. how do i remove the duplctes quickly annd
> without much change.

begin;
alter table foo rename to tmp;
create table foo as select distinct * from tmp;
commit;

You should create a primary key now to avoid duplicated entries...

HTH, Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stijn Vanroye 2006-09-14 07:16:26 Re: select unique items in db
Previous Message a 2006-09-14 04:47:22 Re: select unique items in db