On Thu, Apr 8, 2010 at 6:34 PM, sunpeng <bluevaley@xxxxxxxxx> 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 -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general