Oracle 5.0 Reference Manual page 1276

Table of Contents

Advertisement

If you specify an
dictionary contains a special counter called the auto-increment counter that is used in assigning new
values for the column. This counter is stored only in main memory, not on disk.
uses the following algorithm to initialize the auto-increment counter for a table
InnoDB
an
AUTO_INCREMENT
executes the equivalent of this statement:
InnoDB
SELECT MAX(ai_col) FROM t FOR UPDATE;
increments by one the value retrieved by the statement and assigns it to the column and to the
InnoDB
auto-increment counter for the table. If the table is empty,
a
SHOW TABLE STATUS
has not been initialized,
later inserts. This initialization uses a normal exclusive-locking read on the table and the lock lasts to
the end of the transaction.
follows the same procedure for initializing the auto-increment counter for a freshly created
InnoDB
table.
After the auto-increment counter has been initialized, if you do not explicitly specify a value for an
AUTO_INCREMENT
If you insert a row that explicitly specifies the column value, and the value is bigger than the current
counter value, the counter is set to the specified column value.
If a user specifies
as if the value had not been specified and generates a new value for it.
The behavior of the auto-increment mechanism is not defined if a user assigns a negative value to the
column or if the value becomes bigger than the maximum integer that can be stored in the specified
integer type.
When accessing the auto-increment counter,
that it keeps to the end of the current SQL statement, not to the end of the transaction. The special
lock release strategy was introduced to improve concurrency for inserts into a table containing an
AUTO_INCREMENT
same table simultaneously, which can have a performance impact if the
a long time. That might be the case for a statement such as
that inserts all rows from one table into another.
FROM t2
uses the in-memory auto-increment counter as long as the server runs. When the server is
InnoDB
stopped and restarted,
as described earlier.
A server restart also cancels the effect of the
and
ALTER TABLE
initial counter value or alter the current counter value.
You may see gaps in the sequence of values assigned to the
back transactions that have generated numbers using the counter.
14.2.3.4.
and
InnoDB
This section describes differences in the InnoDB storage engine' handling of foreign keys as compared
with that of the MySQL Server.
Foreign Key Definitions
Foreign key definitions for
Creating and Using
column for an
AUTO_INCREMENT
column named ai_col: After a server startup, for the first insert into a table t,
statement that displays output for the table
initializes but does not increment the value and stores it for use by
InnoDB
column,
increments the counter and assigns the new value to the column.
InnoDB
or
for the
NULL
0
AUTO_INCREMENT
column. Nevertheless, two transactions cannot have the
reinitializes the counter for each table for the first
InnoDB
statements, which you can use with
Constraints
FOREIGN KEY
tables are subject to the following conditions:
InnoDB
Tables
InnoDB
table, the table handle in the
InnoDB
InnoDB
column in an INSERT,
uses a special table-level
InnoDB
INSERT INTO t1 ... SELECT ...
AUTO_INCREMENT = N
tables as of MySQL 5.0.3 to set the
InnoDB
AUTO_INCREMENT
1256
InnoDB
that contains
t
uses the value 1. If a user invokes
and the auto-increment counter
t
treats the row
InnoDB
AUTO-INC
lock on the
AUTO-INC
lock is held for
AUTO-INC
INSERT
table option in
CREATE TABLE
column if you roll
data
lock
to the table,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents