Re: \copy combine with SELECT - Mailing list pgsql-general

From jia ding
Subject Re: \copy combine with SELECT
Date
Msg-id 91ae6e350603160146x1bf2981en21b9a33d4915dec0@mail.gmail.com
Whole thread Raw
In response to Re: \copy combine with SELECT  (Chris <dmagick@gmail.com>)
Responses Re: \copy combine with SELECT  (Chris <dmagick@gmail.com>)
List pgsql-general
yes, of couse COPY

but,
=> copy test to 'test.txt';
ERROR:  must be superuser to COPY to or from a file
HINT:  Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.

On 3/16/06, Chris <dmagick@gmail.com> wrote:
jia ding wrote:
> Hi all,
>
> I tried:
> select id, name  into table2   from table1;
>  \copy table2 to filename.txt
> in order to export 2 columns from table1 to a file.
>
> But, I am thinking, if there is a command can combine these two command
> together?
> Maybe, something like: \copy select id,name  from table  to filename.txt

Close.

copy tablename field1, field2 to 'filename';

http://www.postgresql.org/docs/8.1/static/sql-copy.html

--
Postgresql & php tutorials
http://www.designmagick.com/

pgsql-general by date:

Previous
From: "zagman"
Date:
Subject: How do I make a timestamp column default to current time
Next
From: Leonardo Francalanci
Date:
Subject: Replication & web apps