Re: Can anyone explain how this works?

Поиск
Список
Период
Сортировка
От Joel Burton
Тема Re: Can anyone explain how this works?
Дата
Msg-id Pine.LNX.4.21.0104080548130.19671-100000@olympus.scw.org
обсуждение исходный текст
Ответ на Can anyone explain how this works?  (RbrtBrn3@aol.com)
Список 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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Louis-David Mitterrand
Дата:
Сообщение: Re: Maybe a Bug, maybe bad SQL
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Casting numeric to text