tableName(表名称),columnName(自增列名称)
1、删除自增列
alter table tableName drop columnName;--删除自增列
2、添加自增列
alter table tableName add columnName int(0) not null first;--添加自增列
3、设置为主键并自增
alter table tableName modify column columnName int(0) not null auto_increment,add primary key(columnName);
--设置为主键并自增
测试发现如果表的主键字段不止一个时第三个步骤会执行失败。解决方法是先取消掉其他字段的主键标识。