1170: ER_BLOB_KEY_WITHOUT_LENGTH: BLOB/TEXT column used in key specification without a key length
MySQLWhat does it mean?
You used a BLOB or TEXT column in an index/key definition without specifying a prefix length. These types cannot be indexed in full; only the first N characters/bytes can be indexed.
Why does it happen?
Defining an INDEX/UNIQUE/PRIMARY KEY on a TEXT/BLOB column without a length in CREATE TABLE or CREATE INDEX. MySQL requires a prefix length because it cannot index these potentially very large values in full.
How to fix it
Specify a prefix length in the index, such as INDEX (description(255)). Example: ALTER TABLE my_table ADD INDEX idx_description (description(191)); (191 is commonly used with utf8mb4 because of the InnoDB key prefix limit). If full-text search is needed, consider a FULLTEXT index. For fields that should be short and unique, converting the column to VARCHAR may be more appropriate.
More from this engine
- 1836ER_READ_ONLY_MODE: Running in read-only mode
- 3819ER_CHECK_CONSTRAINT_VIOLATED: Check constraint is violated
- 1118ER_TOO_BIG_ROWSIZE: Row size too large
- 1592ER_BINLOG_UNSAFE_STATEMENT: Unsafe statement written to the binary log
- 3140ER_INVALID_JSON_TEXT: Invalid JSON text
- 1526ER_NO_PARTITION_FOR_GIVEN_VALUE: Table has no partition for value
- 1049Unknown database 'name'