mysql自动增长设置

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

例如:现在一张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如何操作如下:

首先设为主键

 

 再自动递增

 

posted @ 2022-12-26 16:38  阿飞藏泪  阅读(454)  评论(0编辑  收藏  举报
1 2 3
4