Error 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key
Error Code | SQLSTATE | Error | Description |
---|---|---|---|
1075 | 42000 | ER_WRONG_AUTO_KEY | Incorrect table definition; there can be only one auto column and it must be defined as a key |
Contents
Possible Causes and Solutions
There can only be one AUTO_INCREMENT column per table, and the column must be defined as a key. Not adhering to either of these restrictions will result in this error. For example:
CREATE OR REPLACE TABLE animals ( id1 MEDIUMINT NOT NULL AUTO_INCREMENT, id2 TINYINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL, PRIMARY KEY (id1), KEY (id2) ); ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key CREATE OR REPLACE TABLE animals ( id1 MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL ); ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key CREATE OR REPLACE TABLE animals ( id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL, PRIMARY KEY (id) ); Query OK, 0 rows affected (0.017 sec)
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.