Search Postgresql Archives

Re: Viewing Database Scheme

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 28, 2006, at 4:12 PM, Rich Shepard wrote:

Please keep replies on the mailing list.

<snip>

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

That's because you've used the wrong syntax.

$ psql contacts -c "\dt" > xrms.tables

This is why I suggested you read the psql man page.

Alternatively, you can use psql's "\o [FILE]" command to redirect query results to a file:
  This creates the file, but it's empty.

I'm curious what's gone wrong here. Nothing seems to be working as it
should.

Likely, the output is buffered. Did you try quitting psql (via \q) before checking the contents of the file.

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

Dude, "pg_dump" is not a psql command, nor is it a SQL command. It's a command-line program. You run it from your shell:

$ pg_dump --schema-only pg_dump > xrms-schema.dmp

  All I get are error messages.

You continually do the wrong things.  Read the man pages.  Seriously.

eric


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux