Oracle 5.0 Reference Manual page 1468

Table of Contents

Advertisement

Replication and Binary Logging Options and Variables
auto_increment_offset
column value. Consider the following, assuming that these statements are executed during the
same session as the example given in the description for
mysql>
SET @@auto_increment_offset=5;
Query OK, 0 rows affected (0.00 sec)
mysql>
SHOW VARIABLES LIKE 'auto_inc%';
+--------------------------+-------+
| Variable_name
+--------------------------+-------+
| auto_increment_increment | 10
| auto_increment_offset
+--------------------------+-------+
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.06 sec)
mysql>
INSERT INTO autoinc2 VALUES (NULL), (NULL), (NULL), (NULL);
Query OK, 4 rows affected (0.00 sec)
Records: 4
Duplicates: 0
mysql>
SELECT col FROM autoinc2;
+-----+
| col |
+-----+
|
5 |
|
15 |
|
25 |
|
35 |
+-----+
4 rows in set (0.02 sec)
If the value of
auto_increment_offset
auto_increment_increment
ignored.
Should one or both of these variables be changed and then new rows inserted into a table containing
an
AUTO_INCREMENT
values is calculated without regard to any values already present in the column,
AUTO_INCREMENT
and the next value inserted is the least value in the series that is greater than the maximum existing
value in the
AUTO_INCREMENT
auto_increment_offset
where
is a positive integer value in the series [1, 2, 3, ...]. For example:
N
mysql>
SHOW VARIABLES LIKE 'auto_inc%';
+--------------------------+-------+
| Variable_name
+--------------------------+-------+
| auto_increment_increment | 10
| auto_increment_offset
+--------------------------+-------+
2 rows in set (0.00 sec)
mysql>
SELECT col FROM autoinc1;
+-----+
| col |
+-----+
|
1 |
|
11 |
|
21 |
|
31 |
+-----+
4 rows in set (0.00 sec)
[1449]
determines the starting point for the
| Value |
|
| 5
|
Warnings: 0
[1446], the value of
column, the results may seem counterintuitive because the series of
column. In other words, the series is calculated like so:
+
×
N
auto_increment_increment
| Value |
|
| 5
|
1448
auto_increment_increment
[1449]
is greater than that of
auto_increment_offset
AUTO_INCREMENT
[1446]:
[1449]
is

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents