Re: Search for restricting foreign keys
От | Michael Fuhr |
---|---|
Тема | Re: Search for restricting foreign keys |
Дата | |
Msg-id | 20050125061813.GA21776@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Search for restricting foreign keys (Benjamin Smith <lists@benjamindsmith.com>) |
Ответы |
Re: Search for restricting foreign keys
|
Список | pgsql-general |
On Mon, Jan 24, 2005 at 08:35:45PM -0800, Benjamin Smith wrote: > Is there a way in PG 7.3, given a field, to find out what other tables & > records are linked to it via a foreign key? See the "System Catalogs" chapter in the documentation: http://www.postgresql.org/docs/7.3/static/catalogs.html The pg_constraint table contains, among other things, foreign key constraints. By querying it and joining it with pg_attribute, pg_class, and pg_namespace, you could get a list of tables and columns that have foreign key constraints on the given table and column; from that you could build queries to find out which rows in those tables match the given value. You could wrap all this code in a set-returning function. -- Michael Fuhr http://www.fuhr.org/~mfuhr/
В списке pgsql-general по дате отправления: