pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oleg Bartunov <oleg@sai.msu.su>
To: Grega Bremec <gregab@p0f.net>
Cc: andy.shellam@mailnetwork.co.uk
Cc: pgsql-admin@postgresql.org
Subject: Re: Show tables query
Date: Sun, 2 Apr 2006 13:46:35 +0400 (MSD)
Message-ID: <Pine.GSO.4.63.0604021345450.1515@ra.sai.msu.su> (raw)
In-Reply-To: <442F9AA3.7060608@p0f.net>
References: <20060402090706.6EB0911F6B01@postgresql.org>
	<442F9AA3.7060608@p0f.net>

On Sun, 2 Apr 2006, Grega Bremec wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>
> Andy Shellam wrote:
> | Hi,
> |
> | Is there an SQL command supported by Postgres to return a list of
> | tables in a database?
> |
> | For example on mySQL, you can connect to a database and issue the
> | command SHOW TABLES to bring back a list of tables in that database.
> | In PG this throws the error "unknown configuration parameter TABLES.">
>
> Hello, Andy.
>
> Not a command per se, but there are two ways you can obtain this
> information, depending on where you're working.
>
> The first option is the backslash commands you can use from f.e. psql
> (type \? in a psql prompt to see the full list), where \d will list all
> sorts of database objects, \dt can be used specifically for tables.
>
> The other option which you can use from an SQL script is accessing the
> system tables pg_class, pg_namespace and pg_tablespace in schema
> pg_catalog, using a query similar to those used by the backslash commands:
>
> ~  template1=# SELECT c.relname AS table FROM pg_class c
> ~                      LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
> ~                      WHERE n.nspname = 'public'
> ~                      AND c.relkind = 'r';
>
> Substitute 'public' for whatever schema you're interested in or add
> other schemas according to your preference. Also, take a look at system
> view pg_tables (\d pg_tables).
>
> Also, take a look at the archives, Elein once posted a nice set of views
> ~ and statements you can use for such purposes.

psql -E will show you all queries that  internal commands generate


>
> Hope this helped,
> - --
> ~    Grega Bremec
> ~    gregab at p0f dot net
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.0 (GNU/Linux)
>
> iD8DBQFEL5qjfu4IwuB3+XoRA7CDAKCBFI7749wtFfsf4GXm3JcPQBU81gCffZMT
> GbeTZzo0T3RJBwvwlK61O9c=
> =NhhS
> -----END PGP SIGNATURE-----
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>              http://archives.postgresql.org
>

 	Regards,
 		Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83



view thread (12+ messages)  latest in thread

Message-ID: <Pine.GSO.4.63.0604021345450.1515@ra.sai.msu.su>
Permalink:  ../Pine.GSO.4.63.0604021345450.1515@ra.sai.msu.su/
Also on:    postgresql.org/message-id/Pine.GSO.4.63.0604021345450.1515@ra.sai.msu.su

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: oleg@sai.msu.su, gregab@p0f.net, andy.shellam@mailnetwork.co.uk
  Subject: Re: Show tables query
  In-Reply-To: <Pine.GSO.4.63.0604021345450.1515@ra.sai.msu.su>
  References: <20060402090706.6EB0911F6B01@postgresql.org> <442F9AA3.7060608@p0f.net> <Pine.GSO.4.63.0604021345450.1515@ra.sai.msu.su>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox