Re: How to delete completely duplicate rows

From: bricklen <bricklen(at)gmail(dot)com>
To: Janek Sendrowski <janek12(at)web(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to delete completely duplicate rows
Date: 2014-01-01 16:45:54
Message-ID: CAGrpgQ-g9m0YTAupqe6VTjg6tb65cYHwZFrTAnpyU0FjpFnWsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jan 1, 2014 at 4:14 AM, Janek Sendrowski <janek12(at)web(dot)de> wrote:

> 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?

http://postgres.cz/wiki/PostgreSQL_SQL_Tricks#Delete_duplicate_rows_with_window_analytic_functions
http://wiki.postgresql.org/wiki/Deleting_duplicates

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Reiser, John J. 2014-01-01 16:53:16 duplicate OID issue when using pg_upgrade to move from 8.4 to 9.2
Previous Message Jayadevan M 2014-01-01 13:17:47 Re: Refresh Materialized View