Re: [SQL] how can tell if a column is a primary key?

From: Howie <caffeine(at)toodarkpark(dot)org>
To: Mark Stosberg <mark(at)summersault(dot)com>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] how can tell if a column is a primary key?
Date: 1999-11-15 22:37:11
Message-ID: Pine.LNX.3.96.991115223457.7736Z-100000@rabies.toodarkpark.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sun, 14 Nov 1999, Mark Stosberg wrote:

>
> Hello!
>
> I'm writing some perl code to access arbitrary Postgres tables. As part
> of this, I would like to be to tell if a given column is a primary key.
> Given a table and a column name, is there is a select statement I can
> run on the systems tables to tell me whether or not it's a primary key? Thanks.

youd also need to check all the indices for the table; although the field
may not be the pk, it may be in a unique index or part of a unique index.

check psql's source code, which has the appropriate select statements.

---
Howie <caffeine(at)toodarkpark(dot)org> URL: http://www.toodarkpark.org
"Tell a man that there are 400 billion stars and he'll believe you.
Tell him a bench has wet paint and he has to touch it."

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 1999-11-15 23:36:57 Re: [SQL] Verificate values in other table?
Previous Message Bruce Stephens 1999-11-15 19:57:46 Re: [SQL] NULL