From: | Dimitrios Apostolou <jimis(at)gmx(dot)net> |
---|---|
To: | 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:05:12 |
Message-ID: | c691b848-7649-e425-b066-c1116147de55@gmx.net |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, 14 Apr 2025, Dimitrios Apostolou wrote:
> On Mon, 14 Apr 2025, Tom Lane wrote:
>
>> Dimitrios Apostolou <jimis(at)gmx(dot)net> writes:
>>> While doing TRUNCATE ONLY I get:
>>> ERROR: cannot truncate a table referenced in a foreign key constraint
>>> But in my case the table to be truncated is already empty, and the
>>> TRIGGERS are disabled in all tables.
>>
>> IIRC, it will let you do it if you truncate both the referenced and
>> referencing tables in the same command. The state of the triggers
>> is not material to this, since TRUNCATE doesn't fire them anyway.
>
> Thanks Tom, however that is not possible in my case, the referenced table is
> possibly just populated and potentially very big (partitioned table with many
> sub-partitions).
Terminology correction: I meant the *referencing* table has just been
populated. I'm trying to delete the *referenced* table and I get the
error.
Dimitris
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2025-04-14 15:07:58 | Re: TRUNCATE ONLY with foreign keys and triggers disabled |
Previous Message | Dimitrios Apostolou | 2025-04-14 14:53:20 | Re: TRUNCATE ONLY with foreign keys and triggers disabled |