1386
MariaDBerrorddlhigh confidence
This table type requires a primary key
Production Risk
Low — DDL fails; no data affected.
What this means
An attempt was made to create or alter a table without a primary key when the sql_require_primary_key system variable is enabled, or when using a replication topology that requires it.
Why it happens
- 1sql_require_primary_key = ON (available from MySQL 8.0.13)
- 2Group Replication requires all tables to have a primary key
- 3NDB Cluster tables require a primary key
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (name VARCHAR(100));
expected output
ERROR 1386 (HY000): This table type requires a primary key
Fix
Add a primary key
Add a primary key
CREATE TABLE t (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100));
Why this works
Satisfies the primary key requirement.
What not to do
✕
Version notes
Sources
Official documentation ↗
MySQL 8.0 — 1386 ER_REQUIRES_PRIMARY_KEY
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev