Re: [SQL] VIEWs and FOREIGN keys

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] VIEWs and FOREIGN keys
Дата
Msg-id 8541.1023741500@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [SQL] VIEWs and FOREIGN keys  (terry@greatgulfhomes.com)
Список pgsql-general
terry@greatgulfhomes.com writes:
> I would just like to elaborate, and clarify if my understanding is correct:
> The implication of below is that you need a trigger in the foreign key
> target table on the DELETE event, so the foreign key table only lets you
> delete a row if there are no other tables refering to the key you want to
> delete.
> Views cannot have triggers, hence cannot have a DELETE trigger, therefore
> that is why the view cannot be a foreign key target table.

Got it in one.

One could perhaps imagine putting triggers on the table(s) that are
referenced by the view, but those triggers would have to do very slow
and expensive things to enforce the deletion constraint, at least in the
interesting cases where the view is a join, aggregation, GROUP BY, etc...

            regards, tom lane

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

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: logging to a file
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: Help with data transfer please