Return-Path: owner-postman 
Delivery-Date: Tue, 25 Jan 94 13:01:31 -0800
Return-Path: owner-postman
Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id MAA00747 for postgres-list; Tue, 25 Jan 1994 12:56:59 -0800
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199401252056.MAA00747@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from gso.SAIC.COM (gefion.gso.saic.com [192.33.134.48]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id MAA00738 for <postgres@nobozo.CS.Berkeley.EDU>; Tue, 25 Jan 1994 12:56:58 -0800
Received: from ratatosk (ratatosk.gso.saic.com) by gso.SAIC.COM (4.1/SMI-4.1)
	id AA14780; Tue, 25 Jan 94 12:56:47 PST
Received: by ratatosk (4.1/SMI-4.1)
	id AA01862; Tue, 25 Jan 94 12:56:47 PST
Date: Tue, 25 Jan 94 12:56:47 PST
From: jean@gso.SAIC.COM (Jean Anderson)
Message-Id: <9401252056.AA01862@ratatosk>
To: oconnor@MasPar.COM, postgres@postgres.Berkeley.EDU
Subject: Re:  How to query for a class definition?
Resent-To: postgres-list@postgres.Berkeley.EDU
Resent-Date: Tue, 25 Jan 94 12:56:59 -0800
Resent-XMts: smtp

"Jim O'Connor" <oconnor@MasPar.COM> writes:
> The answer to this is probably trivial, but what is the
> query to get the definition of a user-defined class?
> I would like to get back a list of field names and the type of
> each field.

try
     retrieve (r.relname, a.attnum, a.attname, t.typname)
     from    a in pg_attribute, t in pg_type, r in pg_class
     where   a.attrelid = r.oid
     and     a.atttypid = t.oid
     and     r.relname = "student"   /* your class name goes here */
     and     a.attnum > 0            /* system attributes are attnum=0 */
     sort by attnum
     \g

 -jean

