psql \copy from program fails with "The syntax of the command is incorrect"

Viewed 285

I'm trying to import a CSV file into a Postgres table using the psql \copy from program command.

\copy tablename from program 'cmd /c "type file.csv"' with DELIMITER ',' CSV HEADER;

However, this fails with the error message

The syntax of the command is incorrect.
COPY 0
cmd /c "type file.csv": child process exited with exit code 1

What's wrong with my syntax?

I have tried to use simply

\COPY tablename FROM 'file.csv' DELIMITER ',' CSV HEADER;

but this fails with

could not stat file "file.csv": Unknown error

because the file is larger than 1 GB (see ERROR: could not stat file "XX.csv": Unknown error).

I'm using Windows 10 and psql 11.2.

0 Answers
Related