Unable to create partition on Mariadb on this child table where Foreign Key Exists?

0

Issue

Unable to create partition this child table "city" with parent table "country" It is showing below error "Foreign Key Not Supported". Without foreign key how relation maintain

ForeignKey not supported by partition]
[2] https://i.stack.imgur.com/WIlQR.png
[1]: https://i.stack.imgur.com/CpjOv.png

Solution

Partitioning tables with FOREIGN KEY is not supported in MariaDB.

According to the MariaDB documentation:

  • A partitioned table cannot contain, or be referenced
    by, foreign keys.
  • All columns used in the
    partitioning expression for a partitioned table must be part of every
    unique key that the table may have.
  • Each table can contain a maximum of 8192 partitions (from MariaDB
    10.0.4). In MariaDB 5.5 and until 10.0.3, the limit was 1024.

As an alternative to Foreign Keys you could use Triggers to update the partitioned table when a parent table changes.

Recent versions of PostgreSQL do support Foreign Keys for Partitioned Tables. If that is important to you, you might want to have a look there.

Answered By – Louis

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More