Re: [SQL] how can tell if a column is a primary key? - Mailing list pgsql-sql

From Howie
Subject Re: [SQL] how can tell if a column is a primary key?
Date
Msg-id Pine.LNX.3.96.991115223457.7736Z-100000@rabies.toodarkpark.org
Whole thread Raw
In response to how can tell if a column is a primary key?  (Mark Stosberg <mark@summersault.com>)
List 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@toodarkpark.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."



pgsql-sql by date:

Previous
From: Bruce Stephens
Date:
Subject: Re: [SQL] NULL
Next
From: Peter Eisentraut
Date:
Subject: Re: [SQL] Verificate values in other table?