1693
MySQLERRORNotablePartitioningHIGH confidence
A list of fields is not allowed in HASH partitioning
Production Risk
Low — DDL fails; no data is affected.
What this means
HASH and KEY partitioning accept a single column expression; specifying a list of columns using COLUMNS syntax is not permitted for HASH partitioning.
Why it happens
- 1Using PARTITION BY HASH COLUMNS(...) instead of the correct PARTITION BY KEY(...).
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (id INT, dt DATE) PARTITION BY HASH COLUMNS(id, dt) PARTITIONS 4;
expected output
ERROR 1693 (HY000): Only field names allowed as partition expression for HASH.
Fix
Use KEY partitioning for multiple columns
Use KEY partitioning for multiple columns
CREATE TABLE t (id INT, dt DATE) PARTITION BY KEY(id, dt) PARTITIONS 4;
Why this works
KEY partitioning supports multiple columns; HASH requires a single integer expression.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1693 ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev