Re: column refernce question

Поиск
Список
Период
Сортировка
От Jonathan Hedstrom
Тема Re: column refernce question
Дата
Msg-id 45368840.4040805@desc.org
обсуждение исходный текст
Ответ на column refernce question  (Hugo <htakada@gmail.com>)
Список pgsql-general
Hugo wrote:
> Hi, how can I know all the foreign key constrainst that references a
> particular pk ?
>
You can try this:

SELECT c_from.relname  AS table,
(SELECT attname FROM pg_catalog.pg_attribute a WHERE
a.attrelid=c_from.oid AND attnum = array_to_string(conkey,',')) AS column
FROM pg_catalog.pg_constraint co
LEFT JOIN pg_catalog.pg_class c ON (co.confrelid = c.oid)
LEFT JOIN pg_catalog.pg_class c_from ON (co.conrelid = c_from.oid)
WHERE c.relname ~ '^foreign_key_table_name_here$';

cheers,
Jonathan

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

Предыдущее
От: Brad Nicholson
Дата:
Сообщение: Re: Stats Collector Won't Start
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: Drop All the Databases