Getting table metadata - Mailing list pgsql-general

From Ken Tozier
Subject Getting table metadata
Date
Msg-id 0FD53456-69D9-11D9-BE3A-003065F300E2@comcast.net
Whole thread Raw
Responses Re: Getting table metadata
List pgsql-general
<fontfamily><param>Arial</param>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</fontfamily>
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: Michael Fuhr
Date:
Subject: Re: PL/PgSQL Index Usage with Trigger Variables
Next
From: "Dann Corbit"
Date:
Subject: Re: Getting table metadata