Re: MERGE vs REPLACE - Mailing list pgsql-hackers

From Petr Jelinek
Subject Re: MERGE vs REPLACE
Date
Msg-id 4377BF0F.4090201@seznam.cz
Whole thread Raw
In response to Re: MERGE vs REPLACE  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: MERGE vs REPLACE  (Martijn van Oosterhout <kleptog@svana.org>)
Re: MERGE vs REPLACE  (Jochem van Dieten <jochemd@gmail.com>)
List pgsql-hackers
Peter Eisentraut wrote:
> 
> In that regard, MERGE is quite flexible, but MERGE doesn't address the 
> point of REPLACE, because MERGE requires *two* tables as input, whereas 
> REPLACE only takes *one*.  Unless someone can show that you can trick 
> MERGE into doing the REPLACE job anyway, we're not discussing the same 
> thing.
> 

I am really not db expert and I don't have copy of sql standard but you 
don't need to use 2 tables I think - USING part can also be subquery 
(some SELECT) and if I am right then you could simulate what REPLACE 
does because in PostgreSQL you are not forced to specify FROM clause in 
SELECT. So you could in theory do
MERGE INTO tablename USING (SELECT 1 AS myid) ON (tablename.id = myid) ...
But I am not sure if this is what you want.

-- 
Regards
Petr Jelinek (PJMODOS)


pgsql-hackers by date:

Previous
From: Kevin Brown
Date:
Subject: Re: SIGSEGV taken on 8.1 during dump/reload
Next
From: Martijn van Oosterhout
Date:
Subject: Re: MERGE vs REPLACE