Error 1068: Multiple primary key defined
Error Code
SQLSTATE
Error
Description
1068
42000
ER_MULTIPLE_PRI_KEY
Multiple primary key defined
Possible Causes and Solutions
No more than one primary key can be defined per table. Attempting to define more in a single table will result in this error. For example:
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT,
c2 INT NOT NULL,
PRIMARY KEY(c1),
PRIMARY KEY(c2)
);
ERROR 1068 (42000): Multiple primary key defined
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT,
c2 INT NOT NULL,
PRIMARY KEY(c1)
);
It's also possible that this this error results from a mistaken attempt to define a multi-part primary key. This is an example of the correct definition for such a key.
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT,
c2 INT NOT NULL,
PRIMARY KEY(c1, c2)
);
This page is licensed: CC BY-SA / Gnu FDL
PreviousError 1067: Invalid default value forNextError 1069: Too many keys specified; max keys allowed
Last updated
Was this helpful?