From: Sean Chittenden <sean@chittenden.org>
To: Denis Arh <denis@exonium.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Delete duplicates
Date: Sun, 22 Jun 2003 22:22:56 -0700
Message-ID: <20030623052256.GS97131@perrin.int.nxad.com> (raw)
In-Reply-To: <00ac01c33946$8d1678e0$0a00000a@neo>
References: <20030622091522.M37248@oasis.net.au>
<2976.200.59.66.253.1056316636.squirrel@webmail.akyasociados.com.ar>
<00ac01c33946$8d1678e0$0a00000a@neo>
> How to delete "real" duplicates?
>
> id | somthing
> -----------------------
> 1 | aaa
> 1 | aaa
> 2 | bbb
> 2 | bbb
>
> (an accident with backup recovery...)
I'm not 100% on some of the syntax off the top of my head, but:
BEGIN;
ALTER TABLE orig_table RENAME TO backup_table;
CREATE TABLE orig_table AS SELECT id,something FROM backup_table GROUP BY id, something;
-- Create any indexes on orig_table that need to be recreated
DROP TABLE orig_table;
COMMIT;
This isn't for the faint of heart: be sure to do this inside of a
transaction or on a backup db until you're 100% good to go. -sc
--
Sean Chittenden
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sean@chittenden.org, denis@exonium.net
Subject: Re: Delete duplicates
In-Reply-To: <20030623052256.GS97131@perrin.int.nxad.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox