Re: How to detect primary key of a table

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: How to detect primary key of a table
Дата
Msg-id 20060330114048.GA7391@winnie.fuhr.org
обсуждение исходный текст
Ответ на How to detect primary key of a table  ("Sergey Karin" <sergey.karin@gmail.com>)
Список pgsql-general
On Thu, Mar 30, 2006 at 03:13:12PM +0400, Sergey Karin wrote:
> Are there any abilities to detect primary key of a table?

In psql you could use "\d tablename".  To see the queries that psql
makes, execute "\set ECHO_HIDDEN" and then "\d tablename".  Here's
the documentation for the system catalogs that psql queries:

http://www.postgresql.org/docs/8.1/interactive/catalogs.html

You could also query the Information Schema; table_constraints
joined with key_column_usage or constraint_column_usage should
yield a table's primary key columns.

http://www.postgresql.org/docs/8.1/interactive/information-schema.html

--
Michael Fuhr

В списке pgsql-general по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: converting timstamptz to local time zone
Следующее
От: "Tass Chapman"
Дата:
Сообщение: Chasing "signal 11" issues