Re: delete vs insert vs update due to primary key dups -> which is better

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: Ow Mun Heng <Ow(dot)Mun(dot)Heng(at)wdc(dot)com>, pgsql-general(at)postgreSQL(dot)org
Subject: Re: delete vs insert vs update due to primary key dups -> which is better
Date: 2007-08-28 13:06:32
Message-ID: 2FA9844F-C3C7-4183-A310-9F7D5C1C1C8C@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Aug 28, 2007, at 3:10 , Richard Huxton wrote:

> Ow Mun Heng wrote:
>> less typing per insert/update statement so it'll be where a.pkey =
>> b.pkey instead of a.key1 = b.key1 and a.key2 = b.key2
>> and ... up to key5
>
> I'd still leave it alone, but it's your database.

And you can use the row comparison syntax;

WHERE (a.key1, a.key2, a.key3, a.key4, a.key5) = (b.key1, b.key2,
b.key3, b.key4, b.key5)

which I find very convenient as it makes the composite key much
clearer than ANDed equalities.

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marcelo de Moraes Serpa 2007-08-28 13:24:02 difference between function and stored procedure
Previous Message Alvaro Herrera 2007-08-28 12:58:44 Re: INSERT doc discrepancy