Thread: How to view the list of tables?

How to view the list of tables?

From
Konstantin Danilov
Date:
Hello, list!
I need to view the list of tables in a database. In MySQL I can do it with the command "SHOW TABLES". What about
PostgreSQL?
Can I also see somehow the datatypes of tables' fields?
Konstantin

Re: How to view the list of tables?

From
Dick Davies
Date:
* Konstantin Danilov <danilov_konst@list.ru> [0222 10:22]:
> 
> Hello, list!
> I need to view the list of tables in a database. In MySQL I can do it with the command "SHOW TABLES". What about
PostgreSQL?
> Can I also see somehow the datatypes of tables' fields?

\dt in psjl lists tables

( \d gives you things like sequences as well)

\d tablename shows its layout.


-- 
'Tempers are wearing thin. Let's hope some robot doesn't kill everybody.'    -- Bender
Rasputin :: Jack of All Trades - Master of Nuns


Re: [GENERAL] How to view the list of tables?

From
Richard Huxton
Date:
Konstantin Danilov wrote:
> Hello, list!
> I need to view the list of tables in a database. In MySQL I can do it with the command "SHOW TABLES". What about
PostgreSQL?
> Can I also see somehow the datatypes of tables' fields?
> Konstantin

"man psql" will show you details of how to operate the psql application,
or when in it try "\?" and "\h" to get help. We also now support the
SQL-standard "information schema".

You'll also find the manuals have this information - available with your
installation and also online at http://www.postgresql.org/docs/

HTH
--
   Richard Huxton
   Archonet Ltd

Re: How to view the list of tables?

From
Dick Davies
Date:
* Dick Davies <rasputnik@hellooperator.net> [0241 10:41]:
> * Konstantin Danilov <danilov_konst@list.ru> [0222 10:22]:
> > 
> > Hello, list!
> > I need to view the list of tables in a database. In MySQL I can do it with the command "SHOW TABLES". What about
PostgreSQL?
> > Can I also see somehow the datatypes of tables' fields?
> 
> \dt in psjl lists tables

that should be 'psql', obviously..... :)
-- 
'Tempers are wearing thin. Let's hope some robot doesn't kill everybody.'    -- Bender
Rasputin :: Jack of All Trades - Master of Nuns


Re: How to view the list of tables?

From
Mihail Nasedkin
Date:
Hello, Konstantin.

You wrote February, 15 2005 г., 15:16:57:

KD> I need to view the list of tables in a database. In MySQL I
KD> can do it with the command "SHOW TABLES". What about PostgreSQL?

All tables:

select ...
from pg_catalog.pg_class
where c.relkind='r';


All tables of the public schema:

select ...
from pg_catalog.pg_class c join pg_catalog.pg_namespace n on c.relnamespace=n.oid
where c.relkind='r' and n.nspname='public';


KD> Can I also see somehow the datatypes of tables' fields?

select ...
from pg_catalog.pg_class c join pg_catalog.pg_attribute a on
c.oid=a.attrelid join pg_catalog.pg_type t on a.atttypid=t.oid

See also:

\d pg_class
\d pg_namespace
\d pg_attribute
\d pg_type

-- 
rgds,Mihail                          mailto:m.nasedkin.perm@mail.ru



Re: [GENERAL] How to view the list of tables?

From
Shridhar Daithankar
Date:
On Tuesday 15 Feb 2005 3:46 pm, Konstantin Danilov wrote:
> Hello, list!
> I need to view the list of tables in a database. In MySQL I can do it with
> the command "SHOW TABLES". What about PostgreSQL? Can I also see somehow
> the datatypes of tables' fields?

In psql, you can try '\dt' and '\d table name'. Type \? for more commands..

 Shridhar