1495
MariaDBERRORNotablePartitioningHIGH confidence
List of fields is only allowed in KEY partitions
Production Risk
Low — DDL error; the table will not be created.
What this means
ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR (1495, SQLSTATE HY000) is raised when a list of columns is used in a HASH partition definition, which is not supported.
Why it happens
- 1PARTITION BY HASH(col1, col2) — multiple columns are not valid for HASH
- 2Confusion between HASH (single expression) and KEY (multiple columns) partitioning
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (id INT, region VARCHAR(50)) PARTITION BY HASH(id, region) -- Multiple cols not valid for HASH PARTITIONS 4;
expected output
ERROR 1495 (HY000): List of fields is only allowed in KEY partitions
Fix
Use KEY partitioning for multiple columns or a single expression for HASH
Use KEY partitioning for multiple columns or a single expression for HASH
-- Single expression for HASH: CREATE TABLE t (id INT, region VARCHAR(50)) PARTITION BY HASH(id) PARTITIONS 4; -- Multiple columns with KEY: CREATE TABLE t (id INT, region VARCHAR(50)) PARTITION BY KEY(id, region) PARTITIONS 4;
Why this works
HASH partitioning accepts a single integer expression; KEY partitioning accepts a list of column names.
Sources
Official documentation ↗
MySQL 8.0 — 1495 ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev