Re: querying for specs?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: <mjbjr(at)beaudesign(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: querying for specs?
Date: 2001-12-18 06:18:30
Message-ID: 20011217221130.Q57302-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 17 Dec 2001 mjbjr(at)beaudesign(dot)com wrote:

> I'm new to sql and to postgres. I've spent quite a bit of time trying to
> determine answers to the following questions, but have been unsuccessful.
>
> Say you work at a small company, and the person who was db admin dies
> suddenly. How do you:

I'm going to assume you can still get into the server at all.

> 1) determine what db's postgres knows about?
If you mean database names,
select datname from pg_database;
should do what you want.

Since you would need to know a database to connect to before giving the
query I'd suggest "template1" because it's pretty much guaranteed to
exist.

> 2) how do you determine what tables exist, if any, in a given db?
Probably easiest to connect to the database with psql and use:
\d
(see \? for more things you can do from psql)

> 3) how do you determine the structure/specification (not the data) of a table?
Depending on what you want, you might be able to use \d <table>
from psql, but that doesn't give everything. pg_dump -s -t <table> <db>
may be more what you're looking for.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2001-12-18 06:31:55 Re: querying for specs?
Previous Message S P Arif Sahari Wibowo 2001-12-18 05:33:43 Operation on bit strings with different length