Re: Dump and Query

From: Bricklen Anderson <banderson(at)presinet(dot)com>
To: "Andy Shellam (Mailing Lists)" <andy(dot)shellam-lists(at)mailnetwork(dot)co(dot)uk>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Dump and Query
Date: 2006-12-27 16:17:12
Message-ID: 45929C88.6000808@presinet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2006-12-27 16:27:06 Re: psql does not save contents into file at end of command.
Previous Message Enrico 2006-12-27 13:05:30 Dump and Query