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

Поиск
Список
Период
Сортировка
От Howie
Тема Re: [SQL] how can tell if a column is a primary key?
Дата
Msg-id Pine.LNX.3.96.991115223457.7736Z-100000@rabies.toodarkpark.org
обсуждение исходный текст
Ответ на how can tell if a column is a primary key?  (Mark Stosberg <mark@summersault.com>)
Список 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 по дате отправления:

Предыдущее
От: Bruce Stephens
Дата:
Сообщение: Re: [SQL] NULL
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [SQL] Verificate values in other table?