1646
MySQLERRORNotableSchemaHIGH confidence

VALUES in VALUES LESS THAN must be an integer or MAXVALUE

Production Risk

Low — DDL is rejected; no data modified.

What this means

In a RANGE partition definition, the VALUES LESS THAN clause requires an integer literal or MAXVALUE; using a non-integer expression causes this error.

Why it happens
  1. 1Using a string, float, or function call in a VALUES LESS THAN clause.
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 ('100'),
  PARTITION p1 VALUES LESS THAN MAXVALUE
);

expected output

ERROR 1646 (HY000): VALUES value must be of same type as partition function.

Fix

Use integer literals in VALUES LESS THAN

Use integer literals in VALUES LESS THAN
CREATE TABLE t (id INT)
PARTITION BY RANGE (id) (
  PARTITION p0 VALUES LESS THAN (100),
  PARTITION p1 VALUES LESS THAN MAXVALUE
);

Why this works

Integer literals match the RANGE partitioning column type.

Sources
Official documentation ↗

MySQL 8.0 — 1646 ER_VALUES_IS_NOT_INT_TYPE_ERROR

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

← All MySQL errors