0

I would like to copy all data from a csv into a temporary table in order to update a permanent table in PG Admin. I have tried:

CREATE TEMP TABLE tmp_x AS SELECT * FROM "Schema"."Table" LIMIT 0;

copy tmp_x FROM '\\PATH\TO\CSV\FILE.csv' DELIMITER ',' CSV`

Which tells me "ERROR: could not open file "\PATH\TO\CSV\FILE.csv" for reading: No such file or directory"

So then I try the same code but with a backslash before the before "copy" based on this from another thread How to import CSV file data into a PostgreSQL table?

And then I get a syntax error due to the slash: "ERROR: syntax error at or near "\""

Any help would be appreciated

Thanks

Gaz

Community
  • 1
  • 1
GaryBox
  • 33
  • 1
  • 8
  • `COPY` is an SQL command that runs on the server, and looks for a file on the server. `\copy` is a built-in command in the command-line `psql` tool. Neither will help you if what you're trying to do is upload a file from your PC using PgAdmin. The fact that it's a temporary table is irrelevant, and your question is actually, I think "How do I copy data from a CSV on my PC using PgAdmin?" – IMSoP Jan 26 '17 at 16:27
  • `"\PATH\TO\CSV\FILE.csv" for reading: No such file or directory"` The SQL is executed on the server, and the CSV file is presumed to be on the server, too. – wildplasser Feb 01 '17 at 13:05

0 Answers0