Skip site navigation (1) Skip section navigation (2)

Re: mysql replace in postgreSQL?

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: David Fetter <david(at)fetter(dot)org>
Cc: blackwater dev <blackwaterdev(at)gmail(dot)com>,pgsql-general(at)postgresql(dot)org
Subject: Re: mysql replace in postgreSQL?
Date: 2005-10-30 14:52:23
Message-ID: 1130683944.9938.18.camel@Andrea.peacock.de (view raw or flat)
Thread:
Lists: pgsql-general
Am Sonntag, den 30.10.2005, 06:29 -0800 schrieb David Fetter:
> On Fri, Oct 28, 2005 at 09:57:03PM -0400, blackwater dev wrote:
> > In MySQL, I can use the replace statement which either updates the
> > data there or inserts it.  Is there a comporable syntax to use in
> > postgreSQL?
> 
> Not really, but here's an example which doesn't have the brokenness of
> MySQL's REPLACE INTO and doesn't have the race conditions that some
> others' proposals have.
> 
> http://developer.postgresql.org/docs/postgres/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
> 
> Of course, it's not as nice and flexible as the SQL standard MERGE,
> but until that day comes, you can use that example.

In most cases, just DELETE and then INSERT should work perfectly.
(UPDATE and MERGE would cause dead tuples in the same way so in
the end they are only syntactical sugar)

Another way is a rule for insert which turns it into an update 
in case the desired tuple is already existent.



In response to

Responses

pgsql-general by date

Next:From: David FetterDate: 2005-10-30 15:24:40
Subject: Re: mysql replace in postgreSQL?
Previous:From: John Sidney-WoollettDate: 2005-10-30 14:44:42
Subject: Re: Please HELP - URGENT - transaction wraparound error

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group