Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
7d321315
Commit
7d321315
authored
Jul 12, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarified LAST_INSERT_ID() behaviour for multi-row inserts.
Shuffled lines for easier reading. Added missing SQL line.
parent
e81b43eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
Docs/manual.texi
Docs/manual.texi
+9
-3
No files found.
Docs/manual.texi
View file @
7d321315
...
...
@@ -13684,6 +13684,14 @@ Which returns:
+----+---------+
@end example
You can retrieve the used @code{AUTO_INCREMENT} key with the
@code{LAST_INSERT_ID()} SQL function or the @code{mysql_insert_id()} API
function.
Note: for a multi-row insert,
@code{LAST_INSERT_ID()}/@code{mysql_insert_id()} will actually return the
@code{AUTO_INCREMENT} key from the @strong{first} inserted row. This allows
multi-row inserts to be reproduced on other servers.
For MyISAM and BDB tables you can specify @code{AUTO_INCREMENT} on
secondary column in a multi-column key. In this case the generated
value for the autoincrement column is calculated as
...
...
@@ -13694,6 +13702,7 @@ useful when you want to put data into ordered groups.
CREATE TABLE animals (
grp ENUM('fish','mammal','bird') NOT NULL,
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (grp,id)
);
INSERT INTO animals (grp,name) VALUES("mammal","dog"),("mammal","cat"),
...
...
@@ -13716,9 +13725,6 @@ Which returns:
Note that in this case, the @code{AUTO_INCREMENT} value will be reused if you
delete the row with the biggest @code{AUTO_INCREMENT} value in any group.
You can get the used @code{AUTO_INCREMENT} key with the
@code{LAST_INSERT_ID()} SQL function or the @code{mysql_insert_id()} API
function.
@node Batch mode, Twin, Examples, Tutorial
@section Using @code{mysql} in Batch Mode
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment