简体   繁体   English

PostgreSQL Copy 命令如何在 Windows 上工作?

[英]How PostgreSQL Copy command work on Windows?

I need to copy table data into text file on Windows in csv format.我需要将表格数据以 csv 格式复制到 Windows 上的文本文件中。 How to do that?怎么做?

What I have tried:我尝试过的:

COPY test TO '"E:\\test.csv"' DELIMITER ',' CSV HEADER;

I am receiving an error while executing this query.我在执行此查询时收到错误。 That test.csv file have to create first before copying data into that.在将数据复制到该文件之前,必须先创建该test.csv文件。

ERROR: relative path not allowed for COPY to file SQL state: 42602错误:不允许将相对路径复制到文件 SQL 状态:42602

This will work providing you have permissions.如果您有权限,这将起作用。 It will put the csv file at the root directory of the same drive that Postgresql is installed on, probably C:它将把 csv 文件放在安装 Postgresql 的同一驱动器的根目录下,可能是 C:

COPY test TO '\test.csv' DELIMITER ',' CSV HEADER;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM