How to delete completely duplicate rows

From: "Janek Sendrowski" <janek12(at)web(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: How to delete completely duplicate rows
Date: 2014-01-01 12:14:10
Message-ID: trinity-eb3eb934-ffcb-42f8-bb42-7841c964032f-1388578450214@3capp-webde-bs32
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
 
I want to delete duplicates in my table. I've dropped the unique constraint to insert my data.
My id value is a hash calculated witch the values of the two other columns.
So I want to delete all columns, which are indentical, but keeping one.
 
DELETE FROM table t1 USING table t2 WHERE t1.id = t2.id AND t1.ctid > t2.ctid

But the oids aren't unique enough.
What else could I do?

Janek

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erik Darling 2014-01-01 12:41:21 Re: How to delete completely duplicate rows
Previous Message sramay 2014-01-01 06:07:24 pg_largeobject related issue with 9.2