1383
MariaDBerrorddlhigh confidence
BLOB/TEXT column used in key without key length
Production Risk
Low — DDL fails; no data affected.
What this means
A BLOB or TEXT column was used in an index without specifying a key prefix length.
Why it happens
- 1CREATE INDEX on a TEXT or BLOB column without a prefix length
- 2Adding a TEXT column to a composite key without specifying the prefix length
How to reproduce
trigger — this will error
trigger — this will error
CREATE INDEX idx ON t (text_col);
expected output
ERROR 1383 (HY000): BLOB/TEXT column 'text_col' used in key specification without a key length
Fix 1
Specify a key prefix length
Specify a key prefix length
CREATE INDEX idx ON t (text_col(191));
Why this works
MySQL can only index a prefix of TEXT/BLOB columns; 191 is safe for utf8mb4.
Fix 2
Use a generated column
Use a generated column
ALTER TABLE t ADD COLUMN text_hash VARCHAR(64) AS (MD5(text_col)) STORED, ADD INDEX idx(text_hash);
Why this works
Index the hash of the text for equality lookups.
What not to do
✕
Version notes
Sources
Official documentation ↗
MySQL 8.0 — 1383 ER_BLOB_KEY_WITHOUT_LENGTH
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev