mysql添加一列,并设置自增

在数据库中添加一列,并设置自增

 

注意设置自增时要将该字段设置为主键,如果不指定插入位置则默认为列名的最后。

1 alter table test.student add column indexxx int(14) primary key auto_increment;

 

指定插入在某一列之后

 1 alter table test.student add column indexxx int(14) primary key auto_increment after 列名; 

 

指定插入到第一列

 1 alter table test.student add column indexxx int(14) primary key auto_increment after first; 

 

posted @ 2019-09-19 13:43  寅鸷  阅读(9213)  评论(0编辑  收藏  举报