From: | Kenichiro Tanaka <ketanaka(at)ashisuto(dot)co(dot)jp> |
---|---|
To: | 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 01:50:36 |
Message-ID: | 4BBE87EC.8020000@ashisuto.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello sunpeng
First,I answer this question.
>another question:how postgresql internal knows which
>relations belongs to which database?
When we use "psql" command ,it means "psql -d postgres".
#you can change default parameter to set PGDATABASE (OS parameter)
"-d" indicate your connecting database and this is the ANSWER.
So, it is natural that pg_class does not have "database" field.
We can not access other database with psql without using dblink.
I think we can display some database's pg_class with following command,
============================================================
#DISPLAY "test" and "postgres"'s tables
#Your postgresql have to be installed dblink
#1)create dblink
select dblink_connect('test','host=postgres01 port=1843 dbname=test
user=p843');
select dblink_connect('postgres','host=postgres01 port=1843
dbname=postgres user=p843');
#2) display
select 'test',* from dblink('test','select oid, relname from pg_class')
t1(oid oid, relname text)
union
select 'postgres',* from dblink('postgres','select oid, relname from
pg_class') t1(oid oid, relname text);
============================================================
Thank you
> 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
>
--
================================================
Kenichiro Tanaka
K.K.Ashisuto
http://www.ashisuto.co.jp/english/index.html
================================================
From | Date | Subject | |
---|---|---|---|
Next Message | sunpeng | 2010-04-09 02:33:22 | Re: when i logged in mydb,any sql command used to list all the tables in this mydb? |
Previous Message | Diego Schulz | 2010-04-09 00:10:01 | Re: when i logged in mydb,any sql command used to list all the tables in this mydb? |