Re: Sending query to a file - Mailing list pgsql-novice

From Brett W. McCoy
Subject Re: Sending query to a file
Date
Msg-id Pine.LNX.4.30.0111101624100.2354-100000@chapelperilous.net
Whole thread Raw
In response to Re: Sending query to a file  (Francisco Reyes <lists@natserv.com>)
List pgsql-novice
On Sat, 10 Nov 2001, Francisco Reyes wrote:

> Thanks. That worked.
> Is there a better way to use "\g" than running it after running the query
> initially?
> The description says "send query to backend (and results in [file] or
> |pipe)". For starters when I do "\g" it doesn't seem to go to the backend.
> It processes the last query and I don't get the prompt back until it is
> done.

Why do you need to use \g?  Just terminate your query with a semi-colon
and press enter.  They do the same thing.  If you want to save the result
of a query, start your session with \o [file], and use \o without any
options to make query results go back to stdout.  Or use \g [file] in one
shot.  These are more or less the same:

\o result.txt
SELECT * FROM sometable WHERE id > 12;
\o

SELECT * FROM sometable WHERE id > 12
\g result.txt

-- Brett
                                          http://www.chapelperilous.net/
------------------------------------------------------------------------
You can always pick up your needle and move to another groove.
        -- Tim Leary



pgsql-novice by date:

Previous
From: Francisco Reyes
Date:
Subject: Re: Sending query to a file
Next
From: Mo Holkar
Date:
Subject: Re: SQL Question