List prime key column names

Поиск
Список
Период
Сортировка
От CN
Тема List prime key column names
Дата
Msg-id 1087450967.12422.198600659@webmail.messagingengine.com
обсуждение исходный текст
Список pgsql-general
Hi!

I am trying to retrieve the column names that comprise primary key of a
table.
According to manual, pg_index.indkey is an array of indnatts whose usage
I am unaware of.

CREATE TABLE table1 (
PRIMARY KEY (c1,c2),
c1      SMALLINT,
c2      VARCHAR(10),
c3      VARCHAR(10)
)WITHOUT OIDS;

I need a SQL to list the following 2 rows:

c1
c2

The following SQL fails with error "syntax error at or near "ANY" at
character 214":

select attname
from pg_class,pg_index,pg_attribute
where relname='table1' and relkind='r' and relhaspkey
  and indrelid=pg_class.oid and indisprimary
  and attrelid=pg_class.oid and attnum ANY (indkey)

Helps will be much appreciated!

Regards,
CN

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

Предыдущее
От: "zuhans@iname.com"
Дата:
Сообщение: Re: why no answer? [Fwd: backup and restore just with use
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: why no answer? [Fwd: backup and restore just with use