mysql> create table animals(
-> grp enum('fish', 'mammal', 'bird') not null,
-> id mediumint not null auto_increment,
-> name char(30) not null,
-> primary key(grp,id));
ERROR 1075 (42000): Incorrect table definition; there can be only one auto colum
n and it must be defined as a key
grp ENUM('fish', 'mammal', 'bird') NOT NULL,
id MEDIUMINT NOT NULL AUTO_INCREMENT,
NAME CHAR(30) NOT NULL,
PRIMARY KEY(grp,id),KEY(id));
-> grp enum('fish', 'mammal', 'bird') not null,
-> id mediumint not null auto_increment,
-> name char(30) not null,
-> primary key(grp,id));
Query OK, 0 rows affected (0.02 sec)
-> grp enum('fish', 'mammal', 'bird') not null,
-> id mediumint not null auto_increment,
-> name char(30) not null,
-> primary key(grp,id)) engine=innodb;
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a keymysql> create table animals(
-> grp enum('fish', 'mammal', 'bird') not null,
-> id mediumint not null auto_increment,
-> name char(30) not null,
-> primary key(grp,id)) engine=myisam;
Query OK, 0 rows affected (0.30 sec)现在知道为什么了吧?