pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gilberto Castillo <gilberto.castillo@etecsa.cu>
To: koff10 <koff10@hotmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: upsert example about postgres9.5
Date: Tue, 12 Apr 2016 16:23:54 -0500 (GMT+5)
Message-ID: <58935.192.168.207.54.1460496234.squirrel@webmail.etecsa.cu> (raw)
In-Reply-To: <BLU436-SMTP2450160A5A13245DCBAC474CA950@phx.gbl>
References: <CAE_gQfU4s2pJezO78GfcgdkUWi9FkdD+_DppMxMi6fRUnUcOeg@mail.gmail.com>
	<CAGnEboi83_TcZqJzuGcs6vFASSZ1EoN8m2Q8yXWWj466nOOEiA@mail.gmail.com>
	<BLU436-SMTP2450160A5A13245DCBAC474CA950@phx.gbl>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>


>
> Hi all,
>
> It's known that postgres 9.5 has introduce  upsert  instruction.
> Is somebody can show  me how to use this instruction ?
> Do the UPSERT commande exists in  SQL ?
>


insert into accesos_usuarios (usuarios, accesos)
values ('8kdata',1)
on conflict (usuarios)
do update set
accesos = accesos_usuarios.accesos + EXCLUDED.accesos;

insert into accesos_usuarios (usuarios, accesos)
values ('8kdata',1), ('8kdata2',1)
on conflict do nothing;

Tomado de un presentación de Alvaro Hernadez  En Cuba

-- 
Saludos,
Gilberto Castillo
ETECSA, La Habana, Cuba



-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



view thread (3+ messages)  latest in thread

Message-ID: <58935.192.168.207.54.1460496234.squirrel@webmail.etecsa.cu>
Permalink:  ../58935.192.168.207.54.1460496234.squirrel@webmail.etecsa.cu/
Also on:    postgresql.org/message-id/58935.192.168.207.54.1460496234.squirrel@webmail.etecsa.cu

 · 

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-admin@postgresql.org
  Cc: gilberto.castillo@etecsa.cu, koff10@hotmail.com
  Subject: Re: upsert example about postgres9.5
  In-Reply-To: <58935.192.168.207.54.1460496234.squirrel@webmail.etecsa.cu>

* 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