Skip to content Skip to sidebar Skip to footer

Psql Copy To Csv

in postgresql when running like this I get successful result... \copy (select * from user) To 'test.csv' DELIMITER ',' CSV Header; but when I run like this it fails... \copy (sele

Solution 1:

psql (the PostgreSQL command line client) commands are preceded with a backslash and terminated by return, not a semicolon. A semicolon terminates SQL commands, but \COPY is not SQL command. COPY without a leading backslash would be a SQL command. psql commands are written on a single line.

psql commands are run in your client machine, while SQL commands are run in the server. If you connected to a remote server, \COPY would use a csv file on your client filesystem and COPY a file on server filesystem.

Post a Comment for "Psql Copy To Csv"