Re: Dump and Query - Mailing list pgsql-admin

From Bricklen Anderson
Subject Re: Dump and Query
Date
Msg-id 45929C88.6000808@presinet.com
Whole thread Raw
In response to Re: Dump and Query  ("Andy Shellam (Mailing Lists)" <andy.shellam-lists@mailnetwork.co.uk>)
List pgsql-admin
Andy Shellam (Mailing Lists) wrote:
> Hi Enrico,
>
> The following command will get you a text file of your result-set:
>
> # echo "SELECT customer_id, first_name, sur_name FROM
> users;"|/usr/local/pgsql/bin/psql -U [username] -d [database] > myfile.txt
> # cat myfile.txt

Alternative version:

psql -d <your dbname> -c "SELECT customer_id, first_name, sur_name FROM
users" -o myfile.txt

pgsql-admin by date:

Previous
From: "Shoaib Mir"
Date:
Subject: Re: Dump and Query
Next
From: Tom Lane
Date:
Subject: Re: psql does not save contents into file at end of command.