0

I'm considering to use 'COPY' command to load the text file into table A.

COPY myTable FROM value.txt (DELIMITER('|'));

A table has already 10 rows and the value.txt file also has the same 10 rows but only 1 column value(CheckTime) is different from the previous table data. With SQLite 'on conflict replace' feature, I could manage to keep the other column values the same and only CheckTime value is refreshed.

I need to the same thing in PostgreSQL.

How can I do this thing? Can you share your idea?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Sigularity
  • 917
  • 2
  • 12
  • 28

2 Answers2

1

COPY cannot do this. You will have to COPY the file into a temporary table and then use UPDATE to update the table you want the data in.

Eelke
  • 20,897
  • 4
  • 50
  • 76
0

Load to a staging table and you can perform and insert with an on conflict do.

Performs the same as a merge. Documentation here:

https://www.postgresql.org/docs/9.5/static/sql-insert.html

VynlJunkie
  • 1,953
  • 22
  • 26