In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.