首页 > 数据库 >mysql自动增长设置

mysql自动增长设置

时间:2022-12-26 16:44:21浏览次数:33  
标签:设置 -- auto book 自动 increment mysql id

首先将那个要增长的键设成主键,然后再进行设置初始值和增长步长。

例如:现在一张book表

1 alter table book add id BIGINT; -- 为book表增加一个名称为id,类型为bigint的列
2 alter table book change id id BIGINT not null auto_increment primary key; -- 将id列设置为主键并且自增
1 SET @@auto_increment_increment=3; -- 将自动增长步长设为3
2 SET @@auto_increment_offset=4; -- 将自动增长初始值设为4

在navicat如何操作如下:

首先设为主键

 

 再自动递增

 

标签:设置,--,auto,book,自动,increment,mysql,id
From: https://www.cnblogs.com/daitu66/p/17006154.html

相关文章