Re: Can not drop partition if exist foreign keys

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Олег Самойлов <splarv(at)ya(dot)ru>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Can not drop partition if exist foreign keys
Date: 2023-10-11 11:20:29
Message-ID: 4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2023-10-11 at 14:08 +0300, Олег Самойлов wrote:
> There are two common practice to drop partition from partitioned table: just drop or detach-drop.
> But simple drop don't work if exist foreign key. Example script attached.

That is working as designed. You cannot detach a partition of a table if a
foreign key points to it.

Create the foreign key constraints between the partitions instead.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zwettler Markus (OIZ) 2023-10-11 11:34:19 moving data with pg_dump/pg_restore between database with different locale
Previous Message Alvaro Herrera 2023-10-11 11:17:57 Re: Can not drop partition if exist foreign keys