Re: remote duplicate rows - Mailing list pgsql-general

From A. Kretschmer
Subject Re: remote duplicate rows
Date
Msg-id 20060914061444.GB1258@a-kretschmer.de
Whole thread Raw
In response to remote duplicate rows  ("Junkone" <junkone1@gmail.com>)
Responses Re: remote duplicate rows  (John Sidney-Woollett <johnsw@wardbrook.com>)
Re: remote duplicate rows  (Berend Tober <btober@seaworthysys.com>)
List 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

pgsql-general by date:

Previous
From: "a"
Date:
Subject: Re: select unique items in db
Next
From: Stijn Vanroye
Date:
Subject: Re: select unique items in db