1. 程式人生 > 其它 >【MySQL】自增步長調整

【MySQL】自增步長調整

技術標籤:技術

檢視配置

show variables like '%increment%';

如果:

auto_increment_increment=2

執行:
set @@global.auto_increment_increment = 1;
set @@auto_increment_increment =1;

如果:

auto_increment_offset=2

執行:

set @@global.auto_increment_offset =1;
set @@auto_increment_offset =1;
————————————————
版權宣告:本文為CSDN博主「qq_33508876」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連結及本宣告。
原文連結:https://blog.csdn.net/qq_33508876/article/details/79725543
mysql> show variables like '%increment%';
+-----------------------------+-------+
| Variable_name               | Value |
+-----------------------------+-------+
| auto_increment_increment    | 2     |
| auto_increment_offset       | 1     |
| div_precision_increment     | 4     |
| innodb_autoextend_increment | 64    |
+-----------------------------+-------+
4 rows in set (0.03 sec)

mysql> set @@global.auto_increment_increment = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%increment%';
+-----------------------------+-------+
| Variable_name               | Value |
+-----------------------------+-------+
| auto_increment_increment    | 2     |
| auto_increment_offset       | 1     |
| div_precision_increment     | 4     |
| innodb_autoextend_increment | 64    |
+-----------------------------+-------+
4 rows in set (0.07 sec)

mysql> set @@auto_increment_increment =1;
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> show variables like '%increment%';
+-----------------------------+-------+
| Variable_name               | Value |
+-----------------------------+-------+
| auto_increment_increment    | 1     |
| auto_increment_offset       | 1     |
| div_precision_increment     | 4     |
| innodb_autoextend_increment | 64    |
+-----------------------------+-------+
4 rows in set (0.04 sec)