accessing user table structures from SQL

Started by Vincent Predoehlabout 17 years ago3 messagesgeneral
Jump to latest
#1Vincent Predoehl
vpredoehl@phoenixwebgroup.com

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

--
Vincent

#2Scott Marlowe
scott.marlowe@gmail.com
In reply to: Vincent Predoehl (#1)
Re: accessing user table structures from SQL

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.

#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Vincent Predoehl (#1)
Re: accessing user table structures from SQL

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