Click here to Skip to main content
14,836,641 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
I am using the below way to copy the data from Postgre table to csv file

SQL
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


Please tell me what is wrong..
If there is any other way please tell to export data from postgresql to csv/excel.
Posted
Updated 28-Feb-17 6:00am
Comments
Richard MacCutchan 4-Feb-14 4:27am
   
Give a file path that is not restricted, such as your own documents directory.
[no name] 4-Feb-14 6:23am
   
i gave..but same issue.
Richard MacCutchan 4-Feb-14 8:50am
   
You will need to investigate further why this is happening, as it's impossible for us to guess what your setup is.

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.
   
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
   
Comments
Patrice T 28-Feb-17 16:34pm
   
Only 3 tears too late

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900