vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| ||||
| Rich Shepard <rshepard@appl-ecosys.com> writes: > On Sat, 28 Jan 2006, Eric B. Ridge wrote: > >> 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 Eric left off the database argument (which defaults to your user name), which was a little misleading, but his syntax does work: doug@blinky:~$ psql -c '\dt' gateway List of relations Schema | Name | Type | Owner --------+--------------+-------+---------- ... Redirecting to a file is left as an exercise to the reader. >> 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. When I do this, after exiting 'psql' the file is populated. It may be a buffering issue, as another poster has said. What you can also do is close the file by setting output back to the terminal: gateway=# \o /tmp/foo gateway=# \dt gateway=# \!cat /tmp/foo <--- empty at this point gateway=# \o <--- switch output to the terminal gateway=# \!cat /tmp/foo <--- now it's there List of relations Schema | Name | Type | Owner --------+--------------+-------+---------- I'm really surprised that you managed to think 'pg_dump --schema_only' is an SQL command. It's listed nowhere in the SQL syntax reference, and is listed in the manual as one of the utility commands that are run from the shell. Your flailing about, randomly trying different argument combinations, suggests that you aren't understanding what you read, and aren't bothering to try to understand the error messages you get. You could have figured out the first issue, certainly, by reading manpages and error messages. The second one is a bit tricky unless you understand Unix stdio buffering, which I wouldn't necessarily expect. So I'll give you that one. -Doug ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |