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; 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM