如何将PostgreSQL中的结果数据导出到.CSV? [英] How to export the resulting data in PostgreSQL to .CSV?

查看:485
本文介绍了如何将PostgreSQL中的结果数据导出到.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆