Re: PostgreSQL - Ordering Table based of Foreign Key

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: PostgreSQL - Ordering Table based of Foreign Key
Дата
Msg-id 553c3b6b-93f0-591e-2a48-0c8ab5344d13@gmx.net
обсуждение исходный текст
Ответ на PostgreSQL - Ordering Table based of Foreign Key  (FOUTE K. Jaurès <jauresfoute@gmail.com>)
Ответы Re: PostgreSQL - Ordering Table based of Foreign Key
Список pgsql-general
FOUTE K. Jaurès schrieb am 03.10.2021 um 09:48:
> I want to order tables based on the foreign key so that I can delete
> tables one by one without facing "ERROR: update or delete on table
> "table" violates foreign key constraint. DETAIL: Key is still
> referenced from table"

You can create the foreign key constraints with the "ON DELETE CASCADE" option.
Then Postgres will handle dependencies automatically for you.

But that means that *all* DELETEs will be cascaded.

Unfortunately, there is no DELETE FROM ... CASCADE option (similar to DROP)

Thomas



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

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Re: PostgreSQL - Ordering Table based of Foreign Key
Следующее
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: PostgreSQL - Ordering Table based of Foreign Key