设置自增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;