Re: Finding the primary key of tables

Поиск
Список
Период
Сортировка
От Devrim GÜNDÜZ
Тема Re: Finding the primary key of tables
Дата
Msg-id 1280864020.2667.11.camel@hp-laptop2.gunduz.org
обсуждение исходный текст
Ответ на Finding the primary key of tables  (George Silva <georger.silva@gmail.com>)
Ответы Re: Finding the primary key of tables
Список pgsql-general
On Tue, 2010-08-03 at 16:13 -0300, George Silva wrote:
> I'm building a function which needs to know what is the primary key of
> a
> certain table (all in pgplsql).
>
> I was using select * from information_schema.key_column_usage where
> table_schema='foo' and table_name = 'aaa'; but that will give me
> multiple
> results in case of additional keys in the table.
>
> Any suggestions?

See pg_index.indisprimary column. If it is true, then the it is the PK
of given table.

Regards,
--
Devrim GÜNDÜZ
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
PostgreSQL RPM Repository: http://yum.pgrpms.org
Community: devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org  Twitter: http://twitter.com/devrimgunduz

Вложения

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

Предыдущее
От: David Kerr
Дата:
Сообщение: Re: Question about Idle in TX
Следующее
От: George Silva
Дата:
Сообщение: Re: Finding the primary key of tables