Re: How do I pipe output from query to a file in PostgreSQL?

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: "Penrod, John" <John(dot)Penrod(at)STJUDE(dot)ORG>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How do I pipe output from query to a file in PostgreSQL?
Date: 2009-10-26 21:06:22
Message-ID: 4AE60F4E.4020402@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 26/10/2009 18:03, Penrod, John wrote:
> In oracle:
>
> SPOOL filename.txt
> Select * from customer;
> SPOOL OFF
>
> Results are piped to filename.txt
>
>
> How do I do this from the psql command line?

\g <filename> will execute the query and send the result to <filename>.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2009-10-26 21:36:59 Re: [GENERAL] [ANNOUNCE] PGDay.EU 2009 - approaching fast!
Previous Message Kevin Kempter 2009-10-26 21:03:25 Re: How do I pipe output from query to a file in PostgreSQL?