pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCan anyone explain how this works?
2+ messages / 2 participants
[nested] [flat]
* Can anyone explain how this works?
@ 2001-04-02 18:01 RbrtBrn3@aol.com
0 siblings, 1 reply; 2+ messages in thread
From: RbrtBrn3@aol.com @ 2001-04-02 18:01 UTC (permalink / raw)
To: pgsql-sql
Hi,
I recently posted this same question a few weeks back but lost the reply
someone kindly sent. The question again how exactly does this query work:
it will return all attributes and respective data types of a given table':
select attname, typname
from pg_class c, pg_attribute a, pg_type t
where relname = relation_name and
attrelid = c.oid and
atttypid = t.oid and
attnum > 0
order by attnum;
Many thanks,
Rob Burne.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Can anyone explain how this works?
@ 2001-04-08 09:50 Joel Burton <jburton@scw.org>
parent: RbrtBrn3@aol.com
0 siblings, 0 replies; 2+ messages in thread
From: Joel Burton @ 2001-04-08 09:50 UTC (permalink / raw)
To: RbrtBrn3@aol.com; +Cc: pgsql-sql
On Mon, 2 Apr 2001 RbrtBrn3@aol.com wrote:
> Hi,
>
> I recently posted this same question a few weeks back but lost the reply
> someone kindly sent. The question again how exactly does this query work:
>
> it will return all attributes and respective data types of a given table':
>
> select attname, typname
> from pg_class c, pg_attribute a, pg_type t
> where relname = relation_name and
> attrelid = c.oid and
> atttypid = t.oid and
> attnum > 0
> order by attnum;
Understanding a few minutes' worth of the system tables hold will help a
lot here--you can find that in the Developer's Guide.
Eseentially, pg_class hold "classes" (ie tables, views, sequences,
etc.) pg_attribute holds "Attributes" (ie fields). This query joins
togetehr pg_class and pg_Attribute, showing you all attributes for a class
with name = 'relation name'. attnum > 0 is perhaps the only
odd part -- it has to do w/hiding certain system columns of tables that
ordinary users don't realize are there are don't care about.
--
Joel Burton <jburton@scw.org>
Director of Information Systems, Support Center of Washington
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-04-08 09:50 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-02 18:01 Can anyone explain how this works? RbrtBrn3@aol.com
2001-04-08 09:50 ` Joel Burton <jburton@scw.org>
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