导出表格和数据出现错误 > 相对路径不允许在POSTGRES中将文件复制到。

huangapple go评论49阅读模式
英文:

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)

huangapple
  • 本文由 发表于 2023年6月13日 15:41:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76462678.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定