pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Олег Самойлов <splarv@ya.ru>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Can not drop partition if exist foreign keys
Date: Wed, 11 Oct 2023 13:20:29 +0200
Message-ID: <4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at> (raw)
In-Reply-To: <5E197F1B-BDDF-40AF-9D87-D6792CE1A3B9@ya.ru>
References: <5E197F1B-BDDF-40AF-9D87-D6792CE1A3B9@ya.ru>

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





view thread (5+ messages)  latest in thread

Message-ID: <4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at>
Permalink:  ../4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at/
Also on:    postgresql.org/message-id/4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, splarv@ya.ru
  Subject: Re: Can not drop partition if exist foreign keys
  In-Reply-To: <4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at>
  References: <5E197F1B-BDDF-40AF-9D87-D6792CE1A3B9@ya.ru> <4734b034a623e8fa9d7522e4b4b7995cd1f3728f.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox