Re: upsert example about postgres9.5 - Mailing list pgsql-admin

From Gilberto Castillo
Subject Re: upsert example about postgres9.5
Date
Msg-id 58935.192.168.207.54.1460496234.squirrel@webmail.etecsa.cu
Whole thread Raw
In response to Re: upsert example about postgres9.5  (koff10 <koff10@hotmail.com>)
Responses Re: upsert example about postgres9.5
List pgsql-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



pgsql-admin by date:

Previous
From: koff10
Date:
Subject: Re: upsert example about postgres9.5
Next
From: koff10
Date:
Subject: Re: upsert example about postgres9.5