Re: Copy command to handle view for my export requirement - Mailing list pgsql-general

From Raghavendra
Subject Re: Copy command to handle view for my export requirement
Date
Msg-id CA+h6AhgvmgnHCs99XgExs1PgfkC4x3k0nv4jwycBsR4+BfQd-Q@mail.gmail.com
Whole thread Raw
In response to Re: Copy command to handle view for my export requirement  (Siva Palanisamy <siva_p@hcl.com>)
List pgsql-general
COMMAND: copy (select * from employee) to 'C:/emp.csv'
ERROR:  could not open file "C:/emp.csv" for writing: Permission denied
********** Error **********
ERROR: could not open file "C:/emp.csv" for writing: Permission denied
SQL state: 42501

COMMAND: \copy (select * from employee) to 'C:/emp.csv'
ERROR:  syntax error at or near "\"
LINE 1: \copy (select * from employee) to 'C:/emp.csv'
       ^
********** Error **********
ERROR: syntax error at or near "\"
SQL state: 42601

Please correct me where I am going wrong. FYI, I am running under the administrator accounts of both Windows Login and PostgreSQL.

 
Two things,
1. you need to have a proper permissions where the .csv file creating.
2. In windows you need to use as below
postgres=#\copy (select * from employee) to 'C:\\emp.sql' 
 
Regards,
Raghavendra
EnterpriseDB Corporation

pgsql-general by date:

Previous
From: Siva Palanisamy
Date:
Subject: Re: Copy command to handle view for my export requirement
Next
From: Craig Ringer
Date:
Subject: Re: Copy command to handle view for my export requirement