1938
MySQLERRORNotableDDLHIGH confidence
Field is of a not allowed type for this type of partitioning
Production Risk
Low — DDL is rejected.
What this means
The column used in a partition expression has a data type that is not permitted for that partitioning method. For example, FLOAT or DOUBLE columns cannot be used in RANGE or LIST partitioning.
Why it happens
- 1Using a FLOAT, DOUBLE, or DECIMAL column in PARTITION BY RANGE.
- 2Using a BLOB or TEXT column as a partitioning key.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (price FLOAT) PARTITION BY RANGE(price) (PARTITION p0 VALUES LESS THAN (100.0));
expected output
ERROR 1938 (HY000): Field 'price' is of a not allowed type for this type of partitioning.
Fix
Use an integer or RANGE COLUMNS with allowed types
Use an integer or RANGE COLUMNS with allowed types
-- Cast to INT or use an integer surrogate column CREATE TABLE t (price DECIMAL(10,2), price_group INT) PARTITION BY RANGE(price_group) (PARTITION p0 VALUES LESS THAN (100));
Why this works
RANGE and LIST partitioning accept only integer-returning expressions; RANGE COLUMNS additionally supports date and string types.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1938 ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD2
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev