4131
MariaDBERRORNotableMEDIUM confidence
NULL column used in unique index (check configuration)
Production Risk
Low — DDL fails; no data is affected.
Why it happens
- 1A column used in a unique index is NULL-able and the storage engine does not support it in this configuration.
- 2The index context requires NOT NULL columns.
Fix
Add NOT NULL constraint to the indexed column
Add NOT NULL constraint to the indexed column
ALTER TABLE t MODIFY col INT NOT NULL;
Why this works
Making the column NOT NULL ensures unique index behavior is well-defined.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 4131 ER_NULL_COLUMN_IN_INDEX2
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev