DROP TABLE IF EXISTS t1; CREATE TABLE t1(a INT NOT NULL, b INT) ENGINE = INNODB; INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); ALTER TABLE t1 ADD PRIMARY KEY(b), ADD UNIQUE INDEX(a); ERROR 23000: Duplicate entry '1' for key 'a' DROP TABLE t1;