Re: How to retrive List of Tables in a Database using...

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to retrive List of Tables in a Database using...
Date: 2010-03-25 05:26:20
Message-ID: 4BAAF3FC.1070207@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yogi Yang 007 wrote:
> Hello,
>
> I am new to pgSQL. I would like to know if there is a way to do the
> following using pure SQL:
> 1. Retrieve list of all Tables in a database
> 2. Retrieve list of all Functions, Triggers, Sequences, Views, etc.
> 3. Retrieve list of all Group Roles
> 4. Retrieve list of all Login Roles
> 5. Structure of a Table

most of that stuff can be fetched from the INFORMATION_SCHEMA, such as ..

select * from information_schema.tables where table_schema not in
('pg_catalog','information_schema');

select * from information_schema.columns where
table_schema='schemaname' and table_name='tablename';

note, * on both of these returns a lot of data, you may want to be more
selective, depending on just what infoyou need to know, especially about
the columns.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Mead 2010-03-25 06:15:59 Re: How to retrive List of Tables in a Database using...
Previous Message Tadipathri Raghu 2010-03-25 04:37:44 Re: "\d pg_class" fails in PG 8.4