pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow does this query work.....?
2+ messages / 2 participants
[nested] [flat]
* How does this query work.....?
@ 2001-03-09 10:29 RbrtBrn3@aol.com
0 siblings, 1 reply; 2+ messages in thread
From: RbrtBrn3@aol.com @ 2001-03-09 10:29 UTC (permalink / raw)
To: pgsql-sql
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.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How does this query work.....?
@ 2001-03-13 02:41 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: RbrtBrn3@aol.com
0 siblings, 0 replies; 2+ messages in thread
From: Stephan Szabo @ 2001-03-13 02:41 UTC (permalink / raw)
To: RbrtBrn3@aol.com; +Cc: 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@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.
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-03-13 02:41 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-09 10:29 How does this query work.....? RbrtBrn3@aol.com
2001-03-13 02:41 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox