3127
MySQLERRORNotableDDLHIGH confidence
ALTER TABLE not supported: table has no primary key
Production Risk
Medium — tables without PKs have poor InnoDB performance regardless of this error.
What this means
The requested in-place ALTER TABLE operation cannot proceed because the InnoDB table has no primary key, which is required for certain online DDL operations.
Why it happens
- 1InnoDB table was created without a PRIMARY KEY.
- 2Attempting an INPLACE operation that requires the clustered index.
How to reproduce
trigger — this will error
trigger — this will error
ALTER TABLE no_pk_table ADD COLUMN extra INT, ALGORITHM=INPLACE;
expected output
ERROR 3127 (HY000): ALGORITHM=INPLACE is not supported. Reason: Table has no primary key.
Fix
Add a primary key first
Add a primary key first
ALTER TABLE no_pk_table ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY FIRST, ALGORITHM=COPY;
Why this works
InnoDB works most efficiently with a primary key. Adding one enables more online DDL options.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3127 ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOPK2
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev