Re: Copy command to handle view for my export requirement

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
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:46:39
Message-ID: 4E43CF2F.1030004@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/08/2011 7:56 PM, Siva Palanisamy wrote:

> FYI, I am using PostgreSQL 8.1.4.

Argh, ogod why?!?!?!

That version is *totally* unsupported on Windows. Not only that, but
you're running an ancient point-release - you are missing *19* patch
releases worth of bug fixes. The latest point-release is 8.1.23 !

Here is a list of all the fixes you are missing out on:

http://www.postgresql.org/docs/8.1/static/release.html

> I have installed Windows version of Postgres 9.0.4 in my windows machine to test the new copy command as detailed in the below e-mails. When I run the command in SQL Editor, I got permission error. But I am running as an administrator.
>
> 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

The COPY command (as distinct from \copy) runs on the server-side so it
has the permissions of the "postgres" user. You must save the file
somewhere the "postgres" user as write access. Either create a folder
and give "full control" to the user "postgres", or write the export
within the existing postgresql data directory.

> 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'

You are not using psql. "\copy" is a psql command. I don't think it's
supported by PgAdmin III, though I could be wrong.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raghavendra 2011-08-11 13:09:35 Re: Copy command to handle view for my export requirement
Previous Message Raghavendra 2011-08-11 12:03:57 Re: Copy command to handle view for my export requirement