From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | RbrtBrn3(at)aol(dot)com |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How does this query work.....? |
Date: | 2001-03-13 02:41:05 |
Message-ID: | Pine.BSF.4.21.0103121839030.98920-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
pg_class holds the relation information (tables, etc)
pg_attribute holds attribute information (attname), it
keeps the oid of the relation it's on in attrelid and the
oid of the type as atttypid
pg_type holds type information (typname)
The attnum>0 is to limit the check to user attributes.
There are additional attributes (oid, xmin, etc...)
defined on the tables that have attnum<0 and you usually
don't care about that.
On Fri, 9 Mar 2001 RbrtBrn3(at)aol(dot)com wrote:
> Hi,
>
> I am using the following query to find the attributes of a given table, and
> their datatypes:
>
> select typname,attname
> from pg_class c, pg_attribute a,pg_type t
> where relname = 'table_name' and
> attrelid = c.oid and
> atttypid = t.oid and
> attnum > 0;
>
> Can anybody explain how this query actually works - I cannot figure it.
> Thanks in advance.
>
> Rob Burne.
>
From | Date | Subject | |
---|---|---|---|
Next Message | Cliff Crawford | 2001-03-13 03:49:12 | Re: SQL Dummy Needs Help |
Previous Message | Tom Lane | 2001-03-13 02:21:58 | Re: Use of the LIMIT clause ? |