1564
MariaDBERRORCommonPartitioningHIGH confidence

Partitioned tables cannot be temporary tables

Production Risk

Low — the CREATE fails; no table is created.

What this means

MySQL does not support creating a temporary table with partitioning.

Why it happens
  1. 1A CREATE TEMPORARY TABLE statement includes a PARTITION BY clause.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TEMPORARY TABLE t (id INT) PARTITION BY HASH(id) PARTITIONS 4;

expected output

ERROR 1564 (HY000): Cannot create a TEMPORARY partitioned table

Fix 1

Use a regular (non-temporary) partitioned table

Use a regular (non-temporary) partitioned table
CREATE TABLE t (id INT) PARTITION BY HASH(id) PARTITIONS 4;

Why this works

Partitioned tables must be persistent; remove TEMPORARY keyword.

Fix 2

Use a non-partitioned temporary table

Use a non-partitioned temporary table
CREATE TEMPORARY TABLE t (id INT);

Why this works

If a temporary table is required, omit the PARTITION BY clause.

Sources
Official documentation ↗

MySQL 8.0 — 1564 ER_PARTITION_NO_TEMPORARY

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors