In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The auto_increment_increment and auto_increment_offset parameters are used in the master master replication to control the operation of the AUTO_INCREMENT field, and different generation rules are used in different nodes to avoid conflicts caused by the same generated sequence. These two parameters can set global and session variables, respectively, and the range of values for each parameter is 1: 65535. Setting these two parameters to 0 results in actually setting the value of these two parameters to 1.
The auto_increment_increment parameter controls the number of intervals between AUTO_INCREMENT field values
Mysql > SHOW VARIABLES LIKE 'auto_inc%'
+-+ +
| | Variable_name | Value |
+-+ +
| | auto_increment_increment | 1 | |
| | auto_increment_offset | 1 | |
+-+ +
2 rows in set (0.00 sec)
Mysql > CREATE TABLE autoinc1
-> (col int not null auto_increment primary key)
->
Query OK, 0 rows affected (0.12 sec)
Mysql > select @ @ auto_increment_increment
+-+
| | @ @ auto_increment_increment |
+-+
| | 1 |
+-+
1 row in set (0.00 sec)
Mysql > set @ @ auto_increment_increment=10
Query OK, 0 rows affected (0.06 sec)
Mysql > select @ @ auto_increment_increment
+-+
| | @ @ auto_increment_increment |
+-+
| | 10 |
+-+
1 row in set (0.00 sec)
Mysql > SHOW VARIABLES LIKE 'auto_inc%'
+-+ +
| | Variable_name | Value |
+-+ +
| | auto_increment_increment | 10 | |
| | auto_increment_offset | 1 | |
+-+ +
2 rows in set (0.00 sec)
Mysql > INSERT INTO autoinc1 VALUES (null), (null), (null)
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
Mysql > SELECT col FROM autoinc1
+-+
| | col |
+-+
| | 1 |
| | 11 |
| | 21 |
+-+
3 rows in set (0.00 sec)
The auto_increment_offset parameter determines the starting value of the AUTO_INCREMENT field
Mysql > set @ @ auto_increment_offset=5
Query OK, 0 rows affected (0.00 sec)
Mysql > SHOW VARIABLES LIKE 'auto_inc%'
+-+ +
| | Variable_name | Value |
+-+ +
| | auto_increment_increment | 10 | |
| | auto_increment_offset | 5 | |
+-+ +
2 rows in set (0.00 sec)
Mysql > CREATE TABLE autoinc2
-> (col int not null auto_increment primary key)
Query OK, 0 rows affected (0.64 sec)
Mysql > INSERT INTO autoinc2 VALUES (null), (null), (null)
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
Mysql > SELECT col FROM autoinc2
+-+
| | col |
+-+
| | 5 |
| | 15 |
| | 25 |
+-+
3 rows in set (0.00 sec)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.