How to find out whether a row is currently referenced by a row in a different table?

Поиск
Список
Период
Сортировка
От
Тема How to find out whether a row is currently referenced by a row in a different table?
Дата
Msg-id 201007011429.16276@centrum.cz
обсуждение исходный текст
Ответы Re: How to find out whether a row is currently referenced by a row in a different table?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Hello everyone,

does anyone know how to find out whether a row is currently referenced by a row in a different table? They are bound
togetherby a foreign key constraint. 
The reason why I would like to know this is that I would like to be able to delete rows only if they aren't used
anywhere.If this can't be done by a single query, does anyone have such a function they could share or at least a few
hintswhere I could look for more information? 

It occurred to me that I could create a function that would query a system table for all references to the table the
rowwould be deleted from and then scan tables that refer to that one, but I was hoping there would be a simpler and
maybea more efficient way to do this. 

Thanks in advance.

Peter



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

Предыдущее
От: Thom Brown
Дата:
Сообщение: Re: null vs empty string
Следующее
От: Tom Lane
Дата:
Сообщение: Re: How to find out whether a row is currently referenced by a row in a different table?