Skip site navigation (1) Skip section navigation (2)

Re: Viewing Database Scheme

From: "Eric B(dot) Ridge" <ebr(at)tcdi(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Viewing Database Scheme
Date: 2006-01-28 21:20:16
Message-ID: 4DAA52DE-0B5D-4BC8-BC56-8DA20569DA02@tcdi.com (view raw or flat)
Thread:
Lists: pgsql-general
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(at)salmo ~]$ psql -c contacts "\dt" > xrms.tables
> psql: FATAL:  database "\dt" does not exist
>
> [rshepard(at)salmo ~]$ psql "-c contacts \dt" > xrms.tables
> psql: FATAL:  database "rshepard" does not exist
>
> [rshepard(at)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(at)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

In response to

Responses

pgsql-general by date

Next:From: Eric B. RidgeDate: 2006-01-28 21:22:35
Subject: Re: Viewing Database Scheme
Previous:From: Rich ShepardDate: 2006-01-28 21:13:54
Subject: Re: Viewing Database Scheme

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group