ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
The table is created as follows:
mysql> create table tb_emp5(
-> id int(11) not null auto_increment,
-> name varchar(11),
-> deptid int(11) not null auto_increment,
-> salary float,
-> primary key(id,deptid)
-> );
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
when creating a MySQL table, if you want to set auto_increment, you must set the primary key, not null, and only one
After the change is as follows:
mysql> create table tb_emp5(
-> id int(11) not null auto_increment,
-> name varchar(11),
-> deptid int(11) not null,
-> salary float,
-> primary key(id)
-> );
mysql> desc tb_emp5;
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(11) | YES | | NULL | |
| deptid | int(11) | NO | | NULL | |
| salary | float | YES | | NULL | |
+--------+-------------+------+-----+---------+----------------+