I have two Postgres tables:
Table 1
CREATE TABLE tmp.pm_update_20230101 (
fid varchar NULL,
fecha date NULL,
p float4 NULL
);
Table 2
CREATE TABLE aemet.pmes (
indic varchar NOT NULL,
fecha date NOT NULL,
prec float4 NULL,
CONSTRAINT pmes_pkey PRIMARY KEY (indic, fecha)
);
I want to insert or update rows in table 1 with some rows from table 2, but in the following statement I don't know if in excluded.COLUMN I should write excluded.p or excluded.prec
insert into aemet.pmes (indic , fecha, prec)
select t.fid , t.fecha , t.p
from tmp.pm_update_20230101 t
where p is not null
on conflict on constraint pmes_pkey
do update set prec = excluded. COLUMN ;