On Sat, 28 Jan 2006, Eric B. Ridge wrote:
You can't do this via the psql prompt. A simple "\d" will output to the
screen, automatically using your $PAGER if the output is too long to fit on
your screen.
Eric,
That's what I assumed; perhaps I misunderstood Tom Lane's "what do you mean
'ofcourse'?".
Again, you can't use redirection via the psql prompt. But you can do it
via your shell command line:
$ psql -c "\dt" > xrms.tables
Well, that doesn't seem to be working here, either:
[rshepard@salmo ~]$ psql -c contacts "\dt" > xrms.tables
psql: FATAL: database "\dt" does not exist
[rshepard@salmo ~]$ psql "-c contacts \dt" > xrms.tables
psql: FATAL: database "rshepard" does not exist
[rshepard@salmo ~]$ psql -c contacts
psql: FATAL: database "rshepard" does not exist
Alternatively, you can use psql's "\o [FILE]" command to redirect query
results to a file:
contacts=# \o /tmp/xrms.tables
contacts=# \dt
contacts=#
That'll send all output to /tmp/xrms.tables.
This creates the file, but it's empty.
I'm curious what's gone wrong here. Nothing seems to be working as it
should.
You should also read the psql man page and the output of psql's "\h" command.
I've done both and tried various combinations of syntax. For example:
[rshepard@salmo ~]$ psql -d contacts -c pg_dump -o xrms.tables
ERROR: syntax error at or near "pg_dump" at character 1
LINE 1: pg_dump
All I get are error messages.
Thanks,
Rich
--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863