Re: System catalog and identifying - Mailing list pgsql-general

From ville80@salo.salonseutu.fi (9902468)
Subject Re: System catalog and identifying
Date
Msg-id c8493963.0208012233.33cf808f@posting.google.com
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: "Zeb Fropiaz"
Date:
Subject: Recursion in SQL
Next
From: "Ron Harter"
Date:
Subject: Temporal Database