原表中存在主键,则新字段是无法成为主键并变为auto_increment格式的。
1.需要删除原来是主键的那一列或者删去主键,删去主键的方式为:
假设数据表名为Book,则
alter table Book drop primary key;
2.创建新的字段,方法为:
假设列名为book_id,则
alter table Book add column book_id int auto_increment;
原表中存在主键,则新字段是无法成为主键并变为auto_increment格式的。
1.需要删除原来是主键的那一列或者删去主键,删去主键的方式为:
假设数据表名为Book,则
alter table Book drop primary key;
2.创建新的字段,方法为:
假设列名为book_id,则
alter table Book add column book_id int auto_increment;