Re: Getting table metadata - Mailing list pgsql-general

From Dann Corbit
Subject Re: Getting table metadata
Date
Msg-id D425483C2C5C9F49B5B7A41F89441547055810@postal.corporate.connx.com
Whole thread Raw
In response to Getting table metadata  (Ken Tozier <kentozier@comcast.net>)
Responses Re: Getting table metadata
List pgsql-general

Look at the SQL in the PG Admin III project source code base.

http://www.pgadmin.org/

 

It’s non-trivial SQL to collect all the information about a table.

 


From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Ken Tozier
Sent: Tuesday, January 18, 2005 9:15 PM
To: PostgreSQL
Subject: [GENERAL] Getting table metadata

 

I recently stumbled upon the system catalog functions here "http://www.postgresql.org/docs/7.4/static/catalogs.html" and see that it's easy to get a list of all databases and relatively easy to get a list of tables, but there doesn't seem to be any built in method for retrieving a table definition. The best I could come up with would be to do a select something like this:

 

SELECT * FROM pg_attribute WHERE attrelid=<the table oid>;

 

The problem I'm running into however, is that given a table name, there doesn't seem to be any way to get the table oid. Is there some function or query that does this? Better yet, is there an easier way to get at this metadata?

 

Thanks for any help,

 

Ken

pgsql-general by date:

Previous
From: Ken Tozier
Date:
Subject: Getting table metadata
Next
From: Michael Fuhr
Date:
Subject: Re: update in triggers