如何将PostgreSQL中的结果数据导出到.CSV? [英] How to export the resulting data in PostgreSQL to .CSV?
问题描述
我使用PostgreSQL 9.4.1
I use PostgreSQL 9.4.1
我的查询:
copy(select * from city) to 'C:\\temp\\city.csv'
copy(select * from city) to E'C:\\temp\\city.csv'
错误:COPY不允许相对路径归档
**********错误**********
ERROR: relative path not allowed for COPY to file ********** Error **********
错误:COPY不允许相对路径归档SQL状态:42602
ERROR: relative path not allowed for COPY to file SQL state: 42602
推荐答案
与这种情况,您似乎正在尝试使用副本
,而不是托管数据库的计算机。 copy
仅从数据库主机的本地文件系统执行I / O。如果您有权访问该文件系统,则可以相应地调整尝试。否则,您可以使用 \ $ copy 命令在 psql
中。
As with this case, it seems likely that you are attempting to use copy
from a computer other than the one which hosts your database. copy
does I/O from the database host machine's local file system only. If you have access to that filesystem, you can adjust your attempt accordingly. Otherwise, you can use the \copy command in psql
.
这篇关于如何将PostgreSQL中的结果数据导出到.CSV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!