Re: Merge - Insert Select

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: susan(dot)hurst(at)brookhurstdata(dot)com
Cc: "Psql_General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Merge - Insert Select
Date: 2017-10-13 16:43:28
Message-ID: CAH2-WzmqT-5F8uqSL0YELdpN7vbVXygr8i5-j4jejuUn38fM5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 13, 2017 at 9:39 AM, Susan Hurst
<susan(dot)hurst(at)brookhurstdata(dot)com> wrote:
> Does postgres have a MERGE statement ala Oracle?

No.

> I have found examples online for INSERT...ON CONFLICT DO NOTHING, but all of
> those examples use VALUES statements, which is not the scenario that I have.

You can use SELECT instead of VALUES with ON CONFLICT DO NOTHING/ON
CONFLICT DO UPDATE. They don't impose any restriction on the INSERT
statement at all, unlike MERGE, which is fussy about the use of
subqueries.

--
Peter Geoghegan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Seamus Abshere 2017-10-13 16:43:52 Re: "Shared strings"-style table
Previous Message Susan Hurst 2017-10-13 16:39:00 Merge - Insert Select