This table type requires a primary key
Production Risk
Low — DDL fails; no data loss.
ER_SET_CONSTANTS_ONLY (1173, SQLSTATE HY000) is raised when a table is created or converted to a storage engine that requires a primary key (such as NDB Cluster) but no primary key is defined.
- 1CREATE TABLE for NDB Cluster engine without a PRIMARY KEY
- 2ALTER TABLE ... ENGINE=NDB on a table without a primary key
- 3Replication target uses NDB and the source table has no primary key
CREATE TABLE t (name VARCHAR(50)) ENGINE=NDB;
expected output
ERROR 1173 (HY000): This table type requires a primary key
Fix
Add a primary key to the table definition
WHEN Always when using NDB or another engine that requires a primary key.
CREATE TABLE t ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) ) ENGINE=NDB;
Why this works
NDB Cluster requires a primary key on every table for row distribution and retrieval across cluster nodes.
✕ Use InnoDB as a drop-in for NDB without verifying primary key requirements
InnoDB creates a hidden primary key if none is defined; NDB does not. Always define explicit primary keys for portability.
MySQL 8.0 — 1173 ER_SET_CONSTANTS_ONLY
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev