1、mysql删除表中的主键时报错,如下代码所示:
mysql> alter table student drop primary key; ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
2、问题原因:
查看student表的类型时,发现主键列中有auto_increment(递增)类型选项。如要删除表中的主键,需要先删除auto_increment类型。代码如下所示:
mysql> desc student; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | char(20) | NO | MUL | NULL | | | age | tinyint(2) | NO | MUL | 0