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 [EMAIL PROTECTED] 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.
> 


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to