pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Query a list of tables
8+ messages / 5 participants
[nested] [flat]

* Query a list of tables
@ 2008-07-23 14:56  Campbell, Lance <lance@illinois.edu>
  0 siblings, 1 reply; 8+ messages in thread

From: Campbell, Lance @ 2008-07-23 14:56 UTC (permalink / raw)
  To: pgsql-admin

What is the SQL to do the following:

 

1)      Return a list of all possible SCHEMA names within a database.

2)      For a given SCHEMA return the list of all table names.

 

Thanks,

 

Lance Campbell

Project Manager/Software Architect

Web Services at Public Affairs

University of Illinois

217.333.0382

http://webservices.uiuc.edu <http://webservices.uiuc.edu/; 

 

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Query a list of tables
@ 2008-07-23 15:02  Scott Marlowe <scott.marlowe@gmail.com>
  parent: Campbell, Lance <lance@illinois.edu>
  0 siblings, 2 replies; 8+ messages in thread

From: Scott Marlowe @ 2008-07-23 15:02 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: pgsql-admin

On Wed, Jul 23, 2008 at 8:56 AM, Campbell, Lance <lance@illinois.edu> wrote:
> What is the SQL to do the following:
>
>
>
> 1)      Return a list of all possible SCHEMA names within a database.
>
> 2)      For a given SCHEMA return the list of all table names.

You can either do it with the INFORMATION_SCHEMA, or the system
catalogs.  To see how to do it with the system catalogs, then start
psql with the -E switch and issue \dn and set search_path='schemaname'
and \d



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Query a list of tables
@ 2008-07-23 15:10  Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>
  parent: Scott Marlowe <scott.marlowe@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Gibson Chimhamhiwa @ 2008-07-23 15:10 UTC (permalink / raw)
  To: pgsql-admin

Hi All,

I have a postgreSQl database and just wan to know how I can get to its data
dictionary.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Query a list of tables
@ 2008-07-23 15:11  Campbell, Lance <lance@illinois.edu>
  parent: Scott Marlowe <scott.marlowe@gmail.com>
  1 sibling, 2 replies; 8+ messages in thread

From: Campbell, Lance @ 2008-07-23 15:11 UTC (permalink / raw)
  To: Scott Marlowe <scott.marlowe@gmail.com>; +Cc: pgsql-admin

Is there a list somewhere of the system catalog tables and examples of
querying it for administrative reasons?
 
-----Original Message-----
From: Scott Marlowe [mailto:scott.marlowe@gmail.com] 
Sent: Wednesday, July 23, 2008 10:02 AM
To: Campbell, Lance
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Query a list of tables

On Wed, Jul 23, 2008 at 8:56 AM, Campbell, Lance <lance@illinois.edu>
wrote:
> What is the SQL to do the following:
>
>
>
> 1)      Return a list of all possible SCHEMA names within a database.
>
> 2)      For a given SCHEMA return the list of all table names.

You can either do it with the INFORMATION_SCHEMA, or the system
catalogs.  To see how to do it with the system catalogs, then start
psql with the -E switch and issue \dn and set search_path='schemaname'
and \d



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Query a list of tables
@ 2008-07-23 15:21  Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>
  parent: Campbell, Lance <lance@illinois.edu>
  1 sibling, 1 reply; 8+ messages in thread

From: Gibson Chimhamhiwa @ 2008-07-23 15:21 UTC (permalink / raw)
  To: pgsql-admin

Hi,

Under Schema I have;

information_schema
pg_catalog
pg_toast
pg_toast_temp_1
pg_temp_1

and then public which contains the tables with data for my database.

On Wed, Jul 23, 2008 at 5:11 PM, Campbell, Lance <lance@illinois.edu> wrote:

> Is there a list somewhere of the system catalog tables and examples of
> querying it for administrative reasons?
>
> -----Original Message-----
> From: Scott Marlowe [mailto:scott.marlowe@gmail.com]
> Sent: Wednesday, July 23, 2008 10:02 AM
> To: Campbell, Lance
> Cc: pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] Query a list of tables
>
> On Wed, Jul 23, 2008 at 8:56 AM, Campbell, Lance <lance@illinois.edu>
> wrote:
> > What is the SQL to do the following:
> >
> >
> >
> > 1)      Return a list of all possible SCHEMA names within a database.
> >
> > 2)      For a given SCHEMA return the list of all table names.
>
> You can either do it with the INFORMATION_SCHEMA, or the system
> catalogs.  To see how to do it with the system catalogs, then start
> psql with the -E switch and issue \dn and set search_path='schemaname'
> and \d
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>



-- 
Gibson Chimhamhiwa
CSIR - Meraka Institute
P O Box 395, Pretoria 0001
South Africa
www.csir.co.za / www.meraka.org.za
Office: +27 12 841 2758
Mobile: +27 78 447 2879
Fax: +27 12 841 4720
E-mail:gchimhamhiwa@gmail.co.za <E-mail%3Agchimhamhiwa@gmail.co.za>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Query a list of tables
@ 2008-07-23 15:33  Milen A. Radev <milen@radev.net>
  parent: Campbell, Lance <lance@illinois.edu>
  1 sibling, 0 replies; 8+ messages in thread

From: Milen A. Radev @ 2008-07-23 15:33 UTC (permalink / raw)
  To: pgsql-admin

Campbell, Lance написа:
> Is there a list somewhere of the system catalog tables and examples of
> querying it for administrative reasons?
[...]

http://www.postgresql.org/docs/current/static/information-schema.html
http://www.postgresql.org/docs/current/static/catalogs.html

This mostly means you need to acquaint yourself with the fine manual.


-- 
Milen A. Radev




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Query a list of tables
@ 2008-07-23 15:40  Campbell, Lance <lance@illinois.edu>
  parent: Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Campbell, Lance @ 2008-07-23 15:40 UTC (permalink / raw)
  To: Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>; pgsql-admin

Solution:

 

I found that by doing the following query you can get a list of all
schemas or namespaces:

 

select distinct schemaname from pg_tables where schemaname not in
('information_schema', 'pg_catalog');

 

In order to select all of the tables within a schema or namespace:

 

select tablename from pg_tables where schemaname='name_of_schema';

 

Thanks for the responses.

 

From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Gibson
Chimhamhiwa
Sent: Wednesday, July 23, 2008 10:22 AM
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Query a list of tables

 


Hi,

Under Schema I have;

information_schema
pg_catalog
pg_toast
pg_toast_temp_1
pg_temp_1

and then public which contains the tables with data for my database.

On Wed, Jul 23, 2008 at 5:11 PM, Campbell, Lance <lance@illinois.edu>
wrote:

Is there a list somewhere of the system catalog tables and examples of
querying it for administrative reasons?


-----Original Message-----
From: Scott Marlowe [mailto:scott.marlowe@gmail.com]
Sent: Wednesday, July 23, 2008 10:02 AM
To: Campbell, Lance
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Query a list of tables

On Wed, Jul 23, 2008 at 8:56 AM, Campbell, Lance <lance@illinois.edu>
wrote:
> What is the SQL to do the following:
>
>
>
> 1)      Return a list of all possible SCHEMA names within a database.
>
> 2)      For a given SCHEMA return the list of all table names.

You can either do it with the INFORMATION_SCHEMA, or the system
catalogs.  To see how to do it with the system catalogs, then start
psql with the -E switch and issue \dn and set search_path='schemaname'
and \d

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin




-- 
Gibson Chimhamhiwa
CSIR - Meraka Institute
P O Box 395, Pretoria 0001
South Africa
www.csir.co.za / www.meraka.org.za
Office: +27 12 841 2758
Mobile: +27 78 447 2879
Fax: +27 12 841 4720
E-mail:gchimhamhiwa@gmail.co.za
<mailto:E-mail%3Agchimhamhiwa@gmail.co.za>  

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Query a list of tables
@ 2008-07-23 18:22  Igor Neyman <ineyman@perceptron.com>
  parent: Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Igor Neyman @ 2008-07-23 18:22 UTC (permalink / raw)
  To: Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>; pgsql-admin

First you get to Postgresql docs, from there you get anywhere you want.
 
Igor

________________________________

From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Gibson
Chimhamhiwa
Sent: Wednesday, July 23, 2008 11:10 AM
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Query a list of tables


Hi All,

I have a postgreSQl database and just wan to know how I can get to its
data dictionary.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2008-07-23 18:22 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-07-23 14:56 Query a list of tables Campbell, Lance <lance@illinois.edu>
2008-07-23 15:02 ` Scott Marlowe <scott.marlowe@gmail.com>
2008-07-23 15:10   ` Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>
2008-07-23 18:22     ` Igor Neyman <ineyman@perceptron.com>
2008-07-23 15:11   ` Campbell, Lance <lance@illinois.edu>
2008-07-23 15:21     ` Gibson Chimhamhiwa <gchimhamhiwa@gmail.com>
2008-07-23 15:40       ` Campbell, Lance <lance@illinois.edu>
2008-07-23 15:33     ` Milen A. Radev <milen@radev.net>

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