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

Поиск
Список
Период
Сортировка
От Diego Schulz
Тема Re: when i logged in mydb,any sql command used to list all the tables in this mydb?
Дата
Msg-id n2y47dcfe401004081710w73a7d046hfb14daad9679070b@mail.gmail.com
обсуждение исходный текст
Ответ на when i logged in mydb,any sql command used to list all the tables in this mydb?  (sunpeng <bluevaley@gmail.com>)
Список pgsql-general
On Thu, Apr 8, 2010 at 6:34 PM, sunpeng <bluevaley@gmail.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Postgres doesn't seem to enforce array dimensions
Следующее
От: Kenichiro Tanaka
Дата:
Сообщение: Re: when i logged in mydb,any sql command used to list all the tables in this mydb?