Re: How does this query work.....? - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: How does this query work.....?
Date
Msg-id Pine.BSF.4.21.0103121839030.98920-100000@megazone23.bigpanda.com
Whole thread Raw
In response to How does this query work.....?  (RbrtBrn3@aol.com)
List 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
ofthe 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@aol.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.
> 



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Use of the LIMIT clause ?
Next
From: Cliff Crawford
Date:
Subject: Re: SQL Dummy Needs Help