Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

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
  • Cc: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
  • Subject: Outputting select into file.
  • Date: Wed, 19 Dec 2001 15:44:09 +0000 (GMT)
  • Message-id: <15392.46537.511719.871128@elsick.csl.co.uk> <text/plain>

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.



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group