Re: TRUNCATE ONLY with foreign keys and triggers disabled

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Dimitrios Apostolou <jimis(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: TRUNCATE ONLY with foreign keys and triggers disabled
Date: 2025-04-14 15:13:56
Message-ID: ca7e26fa-de54-4b7c-b3b6-c2967ec92f78@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/14/25 08:07, Laurenz Albe wrote:
> On Mon, 2025-04-14 at 17:05 +0200, Dimitrios Apostolou wrote:
>> I meant the *referencing* table has just been
>> populated. I'm trying to delete the *referenced* table and I get the
>> error.
>
> That would break the foreign key constraint, right?
> PostgreSQL cannot allow that.

I believe the OP is disabling all triggers including system ones if I
follow correctly and possibly running a foul of;

https://www.postgresql.org/docs/current/sql-altertable.html

" Disabling or enabling internally generated constraint triggers
requires superuser privileges; it should be done with caution since of
course the integrity of the constraint cannot be guaranteed if the
triggers are not executed."

>
> Yours,
> Laurenz Albe
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitrios Apostolou 2025-04-14 15:20:36 Re: TRUNCATE ONLY with foreign keys and triggers disabled
Previous Message Laurenz Albe 2025-04-14 15:07:58 Re: TRUNCATE ONLY with foreign keys and triggers disabled