Re: Sending query to a file

From: "Brett W(dot) McCoy" <bmccoy(at)chapelperilous(dot)net>
To: Francisco Reyes <lists(at)natserv(dot)com>
Cc: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Sending query to a file
Date: 2001-11-10 21:32:16
Message-ID: Pine.LNX.4.30.0111101624100.2354-100000@chapelperilous.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Mo Holkar 2001-11-11 13:18:14 Re: SQL Question
Previous Message Francisco Reyes 2001-11-10 21:15:19 Re: Sending query to a file