在实际测试工作过程中,有时因为生产环境已有历史数据原因,需要测试环境数据id从某个值开始递增,此时,我们需要修改数据库中自增ID起始值,下面以MySQL为例:

表名:users;

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

建表时添加:

create table users(id int auto_increment primary key,666);

表已创建,修改:

alter table users add id int auto_increment primary key;  #将自增字段设置为primary key
alter table users AUTO_INCREMENT=10000;

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄