MySQL乱弹笔记

auto_increment_increment 和 auto_

2020-11-24  本文已影响0人  醉红尘丶

官网:https://dev.mysql.com/doc/refman/5.7/en/replication-options-source.html#sysvar_auto_increment_increment

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

mysql> set auto_increment_offset=2;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%auto_incre%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| auto_increment_increment | 5     |
| auto_increment_offset    | 2     |
+--------------------------+-------+
2 rows in set (0.00 sec)

mysql> create table t(id int auto_increment primary key);
Query OK, 0 rows affected (0.04 sec)

mysql> insert into t values(NULL), (NULL), (NULL), (NULL);
Query OK, 4 rows affected (0.01 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from t;
+----+
| id |
+----+
|  2 |
|  7 |
| 12 |
| 17 |
+----+
4 rows in set (0.00 sec)
上一篇 下一篇

猜你喜欢

热点阅读