How to Modify the Default Value of AUTO_INCREMENT Allocation

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 如何修改AUTO_INCREMENT分配默认值

| username: foxchan

How to modify the default value of AUTO_INCREMENT allocation in TiDB, for example, change it from 30,000 to 50,000

| username: xingzhenxiang | Original post link

Not sure if this value needs to be set.

| username: 我是咖啡哥 | Original post link

Is this the desired effect?

root@1:4000[test]>CREATE TABLE t(a int AUTO_INCREMENT key);
Query OK, 0 rows affected (0.92 sec)

root@1:4000[test]>set @@session.auto_increment_offset=50000;
Query OK, 0 rows affected (0.01 sec)

root@1:4000[test]>INSERT INTO t VALUES();
Query OK, 1 row affected (1.08 sec)

root@1:4000[test]>select * from t;
+-------+
| a     |
+-------+
| 50000 |
+-------+
1 row in set (0.08 sec)
| username: foxchan | Original post link

It should be this one.

| username: xingzhenxiang | Original post link

Official documentation link. I didn’t see a maximum value limit, you can try it yourself.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.