How to delete duplicate rows?

From: Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to delete duplicate rows?
Date: 2005-02-04 01:04:57
Message-ID: a595de7a050203170413607077@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This one must be obvious for most here.

I have a 170 million rows table from which I want to eliminate
duplicate "would be" keys and leave only uniques.

I found a query in http://www.jlcomp.demon.co.uk/faq/duplicates.html
for the oracle database but can't figure out how to refer to the row
id in postgresql:

delete from test where rowid not in
(select min(rowid) from test group by a,b);

How to refer to the row id? Any better way to do it?

Regards, Clodoaldo Pinto

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2005-02-04 01:13:52 Re: Is there a peer-to-peer server solution with PG?
Previous Message Mike Nolan 2005-02-04 01:03:36 Re: Is there a peer-to-peer server solution with PG?