Re: PostgreSQL - Ordering Table based of Foreign Key

From: FOUTE K(dot) Jaurès <jauresfoute(at)gmail(dot)com>
To: Andreas Joseph Krogh <andreas(at)visena(dot)com>
Cc: Thomas Kellerer <shammat(at)gmx(dot)net>, PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: PostgreSQL - Ordering Table based of Foreign Key
Date: 2021-10-03 14:40:33
Message-ID: CAHQ1jffzXJ_imh5g_34-tpNRVvKB3q=1ogJ=tNW-yRFrwFgVvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for your input but I want to make a delete with where clause

On Sun, 3 Oct 2021, 10:26 Andreas Joseph Krogh, <andreas(at)visena(dot)com> wrote:

> På søndag 03. oktober 2021 kl. 10:49:49, skrev Thomas Kellerer <
> shammat(at)gmx(dot)net>:
>
> 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)
>
>
> There is TRUNCATE ... CASCADE
> https://www.postgresql.org/docs/14/sql-truncate.html
>
> --
> Andreas Joseph Krogh
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2021-10-03 16:19:00 Re: PostgreSQL - Ordering Table based of Foreign Key
Previous Message Christian Ramseyer 2021-10-03 14:01:57 Re: PostgreSQL CHECK Constraint