时间:2021-07-01 10:21:17 帮助过:12人阅读
在实际工作过程中,有时因为生产环境已有历史数据原因,需要测试环境数据id从某个值开始递增,此时,我们需要修改数据库中自增ID起始值,
下面以MySQL为例,表名:users;
- <code class="language-sql">create table users(id int auto_increment primary key,666);
- </code>
- <code class="language-sql">alter table users add id int auto_increment primary key; #将自增字段设置为primary key
- alter table users AUTO_INCREMENT=10000;
- </code>
MySQL中自增ID修改起始值
标签:table 自增字段 历史 sql mysq 自增 数据库 工作 ble