[英]psql copy to csv
in postgresql when running like this I get successful result... 在PostgreSQL中运行时,我得到成功的结果...
\copy (select * from user) To 'test.csv' DELIMITER ',' CSV Header;
but when I run like this it fails... 但是当我这样跑的时候失败了...
\copy
(select * from user)
To 'test.csv' DELIMITER ',' CSV Header;
LINE 2: To 'test.csv' DELIMITER ',' CSV Header;
can someone suggest how to execute with second pattern... 有人可以建议如何使用第二种模式执行...
psql
(the PostgreSQL command line client) commands are preceded with a backslash and terminated by return, not a semicolon. psql
(PostgreSQL命令行客户端)命令以反斜杠开头,并以return而不是分号终止。 A semicolon terminates SQL commands, but \\COPY
is not SQL command. 分号终止SQL命令,但是\\COPY
不是SQL命令。 COPY
without a leading backslash would be a SQL command. 不带反斜杠的COPY
将是一个SQL命令。 psql
commands are written on a single line. psql
命令写在一行上。
psql
commands are run in your client machine, while SQL commands are run in the server. psql
命令在客户端计算机上运行,而SQL命令在服务器上运行。 If you connected to a remote server, \\COPY
would use a csv file on your client filesystem and COPY
a file on server filesystem. 如果连接到远程服务器, \\COPY
将在客户端文件系统上使用csv文件,而在服务器文件系统上使用COPY
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.