Thread: accessing user table structures from SQL

accessing user table structures from SQL

From
Vincent Predoehl
Date:
Does postgresql have a system table that has the table structure of user tables, like systables and sysobjects in MS SQL Server?

-- 
Vincent



Re: accessing user table structures from SQL

From
"Scott Marlowe"
Date:
On Fri, Jan 16, 2009 at 9:32 PM, Vincent Predoehl
<vpredoehl@phoenixwebgroup.com> wrote:
> Does postgresql have a system table that has the table structure of user
> tables, like systables and sysobjects in MS SQL Server?

There's the pg_* views and tables that have all of that, and to see
how they work, you can run psql -E and then any \ command you issue
you'll get to see the SQL for.

OR you can look at the information_schema which is a SQL standard but
I think there are some pg relationships it can't show.

Re: accessing user table structures from SQL

From
"Albe Laurenz"
Date:
Vincent Predoehl wrote:
> Sent: Saturday, January 17, 2009 5:33 AM
> Does postgresql have a system table that has the table
> structure of user tables, like systables and sysobjects in MS
> SQL Server?

All the details about database objects are in the system catalogs:

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

but, unless you need implementation specific details, most
of the time you are better off with the standard SQL
information schema:

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

Yours,
Laurenz Albe