Search Postgresql Archives

Re: PostgreSQL - Ordering Table based of Foreign Key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



På søndag 03. oktober 2021 kl. 10:49:49, skrev Thomas Kellerer <shammat@xxxxxxx>:
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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux