Re: Copy command to handle view for my export requirement

From: Raghavendra <raghavendra(dot)rao(at)enterprisedb(dot)com>
To: Siva Palanisamy <siva_p(at)hcl(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Copy command to handle view for my export requirement
Date: 2011-08-11 12:03:57
Message-ID: CA+h6AhgvmgnHCs99XgExs1PgfkC4x3k0nv4jwycBsR4+BfQd-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
Blog: http://raghavt.blogspot.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-08-11 12:46:39 Re: Copy command to handle view for my export requirement
Previous Message Siva Palanisamy 2011-08-11 11:56:44 Re: Copy command to handle view for my export requirement