3354
MySQLERRORNotableDDL / IndexesHIGH confidence

Functional index cannot be created on a LOB (BLOB/TEXT) column

Production Risk

Low — DDL fails; no index is created.

How to reproduce
trigger — this will error
trigger — this will error
CREATE INDEX idx ON t ((blob_col));

expected output

ERROR 3354 (HY000): Cannot create functional index on a LOB column.

Fix

Use a scalar function

Use a scalar function
CREATE INDEX idx ON t ((MD5(blob_col)));

Why this works

MD5 returns a fixed-length VARCHAR that is fully indexable.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3354 ER_FUNCTIONAL_INDEX_ON_LOB

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors