Re: when i logged in mydb,any sql command used to list all the tables in this mydb?

From: Diego Schulz <dschulz(at)gmail(dot)com>
To: sunpeng <bluevaley(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: when i logged in mydb,any sql command used to list all the tables in this mydb?
Date: 2010-04-09 00:10:01
Message-ID: n2y47dcfe401004081710w73a7d046hfb14daad9679070b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 8, 2010 at 6:34 PM, sunpeng <bluevaley(at)gmail(dot)com> wrote:
> once i have created mydb and several relations in it,are there any sql
> commands used to list all the tables in this mydb?
> i noticed there are no database( pg_database.oid) field in pg_class table,so
> i can not use
> select relname from pg_class,pg_database where pg_database.datname like
> 'mydb' and pg_class.database = pg_database.oid;
> anybody knows how to do it?
> another question:how postgresql internal knows which relations belongs to
> which database?
>
> thanks
>
>

hi,

You can use the -E option for psql, so it will output all querys
executed behind the scenes when you use meta-commands like \dt.
You can then copy and modify those querys to better suit your needs.

Example

$ psql -E mydb
psql (8.4.3)
Type "help" for help.

mydb=# \dt
.. (the query that gets executed is appears here)..

List of relations
Schema | Name | Type | Owner
--------+--------------------------+-------+--------
public | sometable | table | myname

HTH,

diego

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kenichiro Tanaka 2010-04-09 01:50:36 Re: when i logged in mydb,any sql command used to list all the tables in this mydb?
Previous Message Simon Riggs 2010-04-08 23:36:11 Re: Postgres doesn't seem to enforce array dimensions