ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
创建表的时候如下:
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
mysql建表的时候,如果要设置自增(auto_incremetn),必须是主键(primary key)设置,不能为NUll且只能设置一个
更改后如下:
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 | |
+--------+-------------+------+-----+---------+----------------+