How to UPDATE table from csv file?

user2991200 picture user2991200 · Nov 14, 2013 · Viewed 9.4k times · Source

How to update table from csv file in PostgreSQL? (version 9.2.4)

Copy command is for insert. But I need to update table. How can I update table from csv file without temp table?
I don't want to copy to temp table from csv file and update table from temp table.
And no merge command like Oracle?

Answer

Erwin Brandstetter picture Erwin Brandstetter · Nov 15, 2013

The simple and fast way is with a temporary staging table, like detailed in this closely related answer:
How to update selected rows with values from a CSV file in Postgres?

If you don't "want" that for some unknown reason, there are more ways:

Details in this related answer:
Read data from a text file inside a trigger

There is no MERGE command in Postgres, even less for COPY.
Discussion about whether and how to add it is ongoing. Check out the Postgres Wiki for details.