1487
MariaDBERRORNotablePartitioningHIGH confidence

MAXVALUE can only be used in the last partition definition

Production Risk

Low — DDL error; the table will not be created.

What this means

ER_PARTITION_MAXVALUE_ERROR (1487, SQLSTATE HY000) is raised when MAXVALUE is used in a RANGE partition that is not the last partition definition.

Why it happens
  1. 1MAXVALUE placed in a partition that has other partitions defined after it
  2. 2Adding a new partition after a partition that already uses MAXVALUE
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (id INT)
PARTITION BY RANGE(id) (
  PARTITION p0 VALUES LESS THAN MAXVALUE,
  PARTITION p1 VALUES LESS THAN (200)  -- After MAXVALUE
);

expected output

ERROR 1487 (HY000): MAXVALUE can only be used in last partition definition

Fix

Place MAXVALUE only in the last partition

Place MAXVALUE only in the last partition
CREATE TABLE t (id INT)
PARTITION BY RANGE(id) (
  PARTITION p0 VALUES LESS THAN (100),
  PARTITION p1 VALUES LESS THAN (200),
  PARTITION p2 VALUES LESS THAN MAXVALUE  -- Must be last
);

Why this works

MAXVALUE acts as a catch-all for any value not matched by previous partitions; it must be last.

Sources
Official documentation ↗

MySQL 8.0 — 1487 ER_PARTITION_MAXVALUE_ERROR

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

← All MariaDB errors