How to upsert multiple rows in PostgreSQL

How to upsert multiple rows in PostgreSQL

The conflicting values are available through the excluded alias:

INSERT INTO a (id, x)
SELECT id, x 
FROM b
ON CONFLICT (id) DO UPDATE
    SET x = excluded.x;

How to upsert multiple rows in PostgreSQL

Related Posts

Leave a Reply

Your email address will not be published.