pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: greg@turnstep.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Delete 1 Record of 2 Duplicate Records
Date: Thu, 30 Jan 2003 20:16:26 -0500
Message-ID: <4830.1043975786@sss.pgh.pa.us> (raw)
In-Reply-To: <07f0833692070125b9317094e7008b4f@biglumber.com>
References: <07f0833692070125b9317094e7008b4f@biglumber.com>

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



view thread (4+ messages)

Message-ID: <4830.1043975786@sss.pgh.pa.us>
Permalink:  ../4830.1043975786@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4830.1043975786@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, greg@turnstep.com
  Subject: Re: Delete 1 Record of 2 Duplicate Records
  In-Reply-To: <4830.1043975786@sss.pgh.pa.us>

* 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