1173
MySQLERRORCommonDDLHIGH confidence

This table type requires a primary key

Production Risk

Low — DDL fails; no data loss.

What this means

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.

Why it happens
  1. 1CREATE TABLE for NDB Cluster engine without a PRIMARY KEY
  2. 2ALTER TABLE ... ENGINE=NDB on a table without a primary key
  3. 3Replication target uses NDB and the source table has no primary key
How to reproduce
trigger — this will error
trigger — this will error
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.

Add a primary key to the table definition
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.

What not to do

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.

Sources
Official documentation ↗

MySQL 8.0 — 1173 ER_SET_CONSTANTS_ONLY

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

← All MySQL errors