Re: Delete 1 Record of 2 Duplicate Records - Mailing list pgsql-sql

From Tom Lane
Subject Re: Delete 1 Record of 2 Duplicate Records
Date
Msg-id 4830.1043975786@sss.pgh.pa.us
Whole thread Raw
In response to Re: Delete 1 Record of 2 Duplicate Records  (greg@turnstep.com)
List pgsql-sql
greg@turnstep.com writes:
> If they are truly identical, then you must use the hidden 'oid' column to 
> differentiate the two. No need to peek at the oid, just do this:

> DELETE FROM test WHERE oid = (SELECT oid FROM test WHERE column_id=5 LIMIT 1);

Also, if you're unfortunate enough to have this problem in a table with
no OID column, you can play the same trick with the ctid column, which
always exists (it's the physical location of the tuple).  ctid is
dangerous to use for most purposes, because it's not stable over UPDATE
or VACUUM FULL, but it works perfectly well for this kind of problem.
        regards, tom lane


pgsql-sql by date:

Previous
From: Oliver Vecernik
Date:
Subject: Re: Converting clarion
Next
From: Vernon Wu
Date:
Subject: How to rename and drop a column in pg7.3?