1

In this Postgres query,

INSERT INTO TB_PO
SELECT * FROM temporary_table
ON CONFLICT (id) DO UPDATE 
SET id = excluded.id;

Since both the tables tb_po and temporary_table are identical with 26+ columns, is there a way I can specify after the SET, that it will set all columns of the affected row? So that I don't have to manually input each column with SET. thanks

2
  • What version of PostgreSQL ? Commented Jun 1, 2018 at 8:22
  • the PGSQL version is 9.6 Commented Jun 1, 2018 at 8:51

1 Answer 1

0

You could avoid some typing by generating your statement based on the results of

SELECT column_name 
   FROM information_schema.columns 
   WHERE table_name = 'TB_PO'; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.