Outputting select into file.

From: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
To: Troy(dot)Campano(at)libertymutual(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Outputting select into file.
Date: 2001-12-19 15:44:09
Message-ID: 15392.46537.511719.871128@elsick.csl.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Troy(dot)Campano(at)LibertyMutual(dot)com writes:
> I have postgres 7 running on RedHat Linux.
> I was wondering if you knew of a way to run a select and output it to a
> file.
> SELECT * FROM TABLE >> test.out
> So that test.out would have the results from that SQL Statement.

Either:

SELECT * FROM table \g filename

to just output to the file 'filename', or:

select * from lineshoot \g |cat >> /solsolute/path/filename

to append to the file. Both in psql, or:

echo 'SELECT * FROM table' | psql database >> test.out

from your terminal.

Regards, Lee Kindness.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2001-12-19 15:55:12 Re: Way to use count() and LIMIT?
Previous Message Paulo Jan 2001-12-19 15:16:53 Re: Query hangs when getting too complex...