Re: Foreign Key 'walker'?

Поиск
Список
Период
Сортировка
От Erwin Moller
Тема Re: Foreign Key 'walker'?
Дата
Msg-id 4922E6ED.4010102@darwine.nl
обсуждение исходный текст
Ответ на Re: Foreign Key 'walker'?  (ries van Twisk <pg@rvt.dds.nl>)
Список pgsql-general
ries van Twisk schreef:
>
> On Nov 18, 2008, at 9:47 AM, Erwin Moller wrote:
>
>> Hi group,
>>
>> Considering following (simplified) example:
>>
>> CREATE TABLE tblnr1(
>> nr1id SERIAL PRIMARY KEY,
>> firstname TEXT
>> );
>> CREATE TABLE tblnr2(
>> nr2id SERIAL PRIMARY KEY,
>> nr1id INTEGER REFERENCES tblnr1(nr1id)
>> );
>> CREATE TABLE tblnr3(
>>  nr3id SERIAL PRIMARY KEY,
>>  nr2id INTEGER REFERENCES tblnr2(nr2id)
>> );
>>
>> 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)
>> 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)
>> 2) I have a lot of tables and am afraid I miss some. And I am also a
>> bit lazy .-)
>>
>
> Why not use something like this??
>
>   CONSTRAINT fk_tname FOREIGN KEY (nr2id)
>       REFERENCES tblnr2 MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO
> ACTION,
Hi,

Thankf for your reply, but that is NOT what I am looking for.

I want to list the tables that use REFERENCES etc. against my first table.
And deeper (so if other tables references second table then I would like
them too). etc.

Regards,
Erwin Moller

>
>> Thanks for your time.
>>
>> Regards,
>> Erwin Moller
>>
>
>
>
>
>
>
>
>
>
>


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

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: Foreign Key 'walker'?
Следующее
От: "Flavio Palumbo"
Дата:
Сообщение: Re: strange commit behavior