1354
MySQLerrorddlhigh confidence
Column used in key specification without key length cannot be NULL
Production Risk
Low — DDL fails; no data affected.
What this means
A column in a key specification allows NULL values in a context that requires NOT NULL (e.g. certain storage engines or index types).
Why it happens
- 1Adding a spatial index on a nullable column
- 2Specific index requirements of non-InnoDB engines
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (geom GEOMETRY) ENGINE=MyISAM; CREATE SPATIAL INDEX idx ON t(geom);
expected output
ERROR 1354 (42000): Column 'geom' used in key specification without a key length cannot be NULL
Fix
Make the column NOT NULL
Make the column NOT NULL
ALTER TABLE t MODIFY geom GEOMETRY NOT NULL;
Why this works
Satisfies the index requirement for non-nullable columns.
Version notes
Sources
Official documentation ↗
MySQL 8.0 — 1354 ER_NULL_COLUMN_IN_INDEX
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev