英文:
Exporting table and data gives an Error >relative path not allowed for COPY to file in POSTGRES
问题
我想从Postgres导出一个表格。它给我一个"相对路径"错误。有人可以告诉我导出的文件应该保存在哪里吗?
使用了以下SQL语句:
COPY Table_1 TO 'C:/temp/table_1.csv' DELIMITER ',' CSV HEADER
英文:
I would like to do an Export of a table from Postgres.
Its giving me a "relative path" error. Can anyone let me know where the exported file should be saved?
Used the following sql statement
COPY Table_1 TO 'C:/temp/table_1.csv' DELIMITER ',' CSV HEADER
答案1
得分: 1
COPY
将数据写入数据库服务器上的文件。您的数据库服务器必须具有与Windows不同的操作系统,以便不将 C:/temp/table_1.csv
视为绝对路径。事实上,在与Windows不同的操作系统上,该路径将没有意义。
如果您想将表导出到客户端机器上的文件,您需要使用 psql
命令行客户端。然后,您可以使用以下命令:
\copy table_1 TO 'C:/temp/table_1.csv' (FORMAT 'csv', HEADER)
英文:
COPY
writes to a file on the database server. Your database server must have an operating system different from Windows, so it doesn't recognize C:/temp/table_1.csv
as an absolute path. Indeed, that path wouldn't make sense on an operating system different from Windows.
If you want to export a table to a file on the client machine, you need to use the psql
command line client. Then you can use
\copy table_1 TO 'C:/temp/table_1.csv' (FORMAT 'csv', HEADER)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论