设置自增id
通常的设置自增字段的方法:

创建表格时添加:
create table table1(id int auto_increment primary key,…)

创建表格后添加:
alter table table1 add id int auto_increment primary key 自增字段
一定要设置为primary key.

希望table中数据的id不要从1开始 id从100开始,代码如下:
alter table users AUTO_INCREMENT=100;

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐