Re: Retrieving database schema

From: Gary M <postgres-general(at)mwwm(dot)net>
To: Lamar Owen <lamar(dot)owen(at)wgcr(dot)org>
Cc: Gary M <postgres-general(at)mwwm(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Retrieving database schema
Date: 2003-03-23 04:43:32
Message-ID: Pine.LNX.4.44.0303222238550.26061-100000@ruby.gem
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks, the syntax works fine on 7.3.2.

Note that "lower($table)" may not be desirable as you CAN create
mixed-case table and column names, for example...

CREATE TABLE "MixedCase" ( "MixedCase" serial );

On Sat, 22 Mar 2003, Lamar Owen wrote:

> I use the following query, which also gives the type of the column. $table is
> the table in question.
> SELECT a.attname, t.typname
> FROM pg_class c, pg_attribute a, pg_type t
> WHERE c.relname = lower($table)
> and a.attnum > 0 and a.attrelid = c.oid
> and a.atttypid = t.oid
> ORDER BY attname

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas T. Thai 2003-03-23 05:49:54 Crash After Vacuum Analyze
Previous Message Tom Lane 2003-03-23 04:39:41 Re: Retrieving database schema