Re: System catalog and identifying

From: ville80(at)salo(dot)salonseutu(dot)fi (9902468)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: System catalog and identifying
Date: 2002-08-02 06:33:16
Message-ID: c8493963.0208012233.33cf808f@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I got the solution to that problem a few moments after I had posted
the message...

If one has to identify users colums from a table without knowing their
names, use this approach:

In system catalog pg_attribute you have a description of each column,
and attnum identifies if column is a system column or not.If column is
a systemn column it's attnum is negative, if user column, positive.

So to get all user columns from table which attrelid is 25217 use the
following clause:

select attname from pg_attribute where attrelid = '25217' and attnum >
'0';

You can fetch attrelid like this:

select relfilenode from pg_class where relname =
'your_table_name_here';

Now, how one can tell if a column is the primary key column of the
table?

If you know please respond...

Thanks

-9902468

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben Liblit 2002-08-02 08:08:56 Re: huge performance penalty from constraint triggers
Previous Message frank_lupo 2002-08-02 06:15:36 Re: problem insert time into column timestamp