将数据从postgreSql导出到csv [英] Export data from postgreSql to csv

查看:218
本文介绍了将数据从postgreSql导出到csv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我使用以下方式将数据从Postgre表复制到csv文件



Hi all
I am using the below way to copy the data from Postgre table to csv file

Copy (SELECT * from tbl_login) To 'C:\Documents and Settings\All Users\Documents\data.csv' DELIMITER ',' CSV HEADER;





但它给出错误



But it's giving error

ERROR: could not open file "C:\Documents and Settings\All Users\Documents\data.csv" for writing: Permission denied
SQL state: 42501





请告诉我有什么问题..

如果还有其他方法,请告诉我们将数据从postgresql导出到csv / excel。



Please tell me what is wrong..
If there is any other way please tell to export data from postgresql to csv/excel.

推荐答案

您可能从远程计算机触发此查询。此查询将仅在远程桌面上导出服务器上的csv文件。

您必须使用服务器进行此操作。
You might be firing this query from remote computer. This query will export csv file on server only not on your remote desktop.
You have to use server for this operation.


检查导出的位置是否与postgres数据可用,即postgres / data。



COPY Table_Name TO'/home/postgres/data/table_data_export.csv';



这里Table_name:可导出名称

路径:greenplum / data的位置
Check the export the same location as postgres data available, i.e postgres/data.

COPY Table_Name TO '/home/postgres/data/table_data_export.csv';

Here Table_name: exportingtable name
Path: location of greenplum/data


这篇关于将数据从postgreSql导出到csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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