[postgresql-it] upsert - on conflict on constraint... come fare?

  • From: Alessandro Dentella <sandro@xxxxxxxx>
  • To: postgresql-it <postgresql-it@xxxxxxxxxxxxx>
  • Date: Mon, 09 Jan 2017 00:29:22 -0000



Un saluto a tutti,

vorrei usare UPSERT per una semplice tabella così fatta:

# \d call_tarif
                                  Table "public.call_tarif"
  Column  |          Type          |                        Modifiers
----------+------------------------+---------------------------------------------------------
 id       | integer                | not null default 
nextval('call_tarif_id_seq'::regclass)
 provider | character varying(50)  |
 name     | character varying(255) | not null
 cost     | numeric(6,3)           | not null
Indexes:
    "call_tarif_pkey" PRIMARY KEY, btree (id)
    "call_tarif_tarif_provider_idx" btree (provider, name)
Referenced by:
    TABLE "call_call" CONSTRAINT 
"call_call_tarif_id_f389fae33304db5_fk_call_tarif_id" FOREIGN KEY (tarif_id) 
REFERENCES call_tarif(id) DEFERRABLE INITIALLY DEFERRED

[La chiave primaria naturale sarebbe stata (provider, name), essendo
usata via django ho lasciato l'autoincrementale e poi ho aggiunto un
indice sui due campi]



Vorrei fare upsert ovvero INSERT ... ON COMPLAIN sul constraint, come
indicato in documentazione ma mi perdo in un bicchier d'acqua: qual'è
il nome del constraint derivante dall'indice "call_tarif_tarif_provider_idx"?

Quando creo l'indice il contraint si crea in automatico, no?


sandro
*:-)


--
Sandro Dentella  *:-)
http://trepalchi.it                Il portale degli artisti

Other related posts:

  • » [postgresql-it] upsert - on conflict on constraint... come fare? - Alessandro Dentella