3135
MariaDBERRORNotableDDLHIGH confidence
ALTER TABLE not supported: adding NOT NULL requires table copy
Production Risk
Medium — may fail mid-rebuild if NULLs are encountered; always pre-clean data.
What this means
Adding a NOT NULL constraint to an existing column that may contain NULL values cannot be done in-place and requires a full table copy so that existing NULLs can be replaced or rejected.
Why it happens
- 1ALTER TABLE ... MODIFY COLUMN col NOT NULL with ALGORITHM=INPLACE when NULLs may exist.
How to reproduce
trigger — this will error
trigger — this will error
ALTER TABLE t1 MODIFY COLUMN name VARCHAR(100) NOT NULL, ALGORITHM=INPLACE;
expected output
ERROR 3135 (HY000): ALGORITHM=INPLACE is not supported. Reason: NOT NULL requires table copy.
Fix
Update NULLs first, then use COPY algorithm
Update NULLs first, then use COPY algorithm
UPDATE t1 SET name = '' WHERE name IS NULL; ALTER TABLE t1 MODIFY COLUMN name VARCHAR(100) NOT NULL, ALGORITHM=COPY;
Why this works
Eliminates NULLs before enforcing the constraint.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3135 ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL2
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev