Re: Foreign Key 'walker'?

Поиск
Список
Период
Сортировка
От Shane Ambler
Тема Re: Foreign Key 'walker'?
Дата
Msg-id 4922F953.6080306@Sheeky.Biz
обсуждение исходный текст
Ответ на Re: Foreign Key 'walker'?  (ries van Twisk <pg@rvt.dds.nl>)
Ответы Re: Foreign Key 'walker'?  (Erwin Moller <erwin@darwine.nl>)
Список pgsql-general
ries van Twisk wrote:
>
> On Nov 18, 2008, at 9:47 AM, Erwin Moller wrote:
>
>> Hi group,
>>
>> Considering following (simplified) example:
<snip>
>>
>> Suppose I want to delete a record in tblnr1.
>> Does Postgres has some command/procedure/function to list tables that
>> have FK constraints on that table (tblnr1)

The data you are looking for is stored in the system catalogs.
http://www.postgresql.org/docs/8.3/interactive/catalogs.html
You should be able to come up with some SELECT's to get what you want.

>> and lists also the tables that have a FK constraint on tables that
>> have a FK constraint on the first? etc.
>> So I would like some kind of FK 'walker'.
>>
>> I want this because:
>> 1) I hate DELETE CASCADE because I am chicken (So I use a script to
>> delete all related records in the right order in a transaction)

That isn't being chicken it is being silly (or is that just stubborn ;).
PostgreSQL is designed to delete related records that you tell it to
delete. Let it do what it is suppose to do.

>> 2) I have a lot of tables and am afraid I miss some. And I am also a
>> bit lazy .-)

If your lazy why do all this manual work when you can leave it
automated? It won't miss a related record after you tell it to cascade
delete. This is an old well tested feature that you can rely on.


That probably all sounds more aggressive than it should. Not having a
strong dig at you but I do want to emphasise the fact that you shouldn't
waste your time doing manually what the software is designed to do.



--

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: pgsql-general@postgresql.org
Следующее
От: Simon Connah
Дата:
Сообщение: No serial type