Re: FK relationships

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: FK relationships
Дата
Msg-id 20050112193107.GA95870@winnie.fuhr.org
обсуждение исходный текст
Ответ на FK relationships  (sarlav kumar <sarlavk@yahoo.com>)
Ответы Re: FK relationships  (sarlav kumar <sarlavk@yahoo.com>)
Список pgsql-novice
On Wed, Jan 12, 2005 at 10:56:00AM -0800, sarlav kumar wrote:

> Is there an easy way to find out the list of tables that have a
> FK relation on a particular table?

You could query the system catalogs, either directly or via the
Information Schema (the latter is available in 7.4 and later).
See the "System Catalogs" and "The Information Schema" chapters
in the documentation.

> Say, if I have a 'customer' table, I would like to get the tables
> that depend on customer and not the tables on which customer depends.

I think this'll work, although I did only trivial testing with it:

SELECT conrelid::regclass, conname
FROM pg_constraint
WHERE confrelid = 'customer'::regclass AND contype = 'f';

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: sarlav kumar
Дата:
Сообщение: FK relationships
Следующее
От: sarlav kumar
Дата:
Сообщение: Re: FK relationships