【发布时间】:2011-12-28 11:47:03
【问题描述】:
我需要将 PostgreSQL 中查询的结果数据导出到 Excel/CSV。
我用PostgreSQL 8.2.11。
SQL error:
ERROR: relative path not allowed for COPY to file
In statement:
COPY (select distinct(m_price) from m_product)TO '"c:\auto_new.txt"';
【问题讨论】:
-
名称为
PostgreSQL或简称Postgres。没有Postgre。 -
如果文件名包含空格或特殊字符,您只需要双引号。
'C:\\auto_new.txt'不需要。 (虽然没有错。)。有 -
我尝试给 >TO 'C:\\auto_new.txt' 但同样的错误
-
TO前面也少了一个空格。不确定 PostgreSQL 8.2 是否关心。它仍然可以在 9.0 中使用。
标签: postgresql file-io postgresql-copy