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
c883dacd
Commit
c883dacd
authored
Jul 12, 2002
by
arjen@fred.bitbike.com
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
28c2277b
Changes
1
Show 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 @
c883dacd
...
@@ -13684,6 +13684,14 @@ Which returns:
...
@@ -13684,6 +13684,14 @@ Which returns:
+----+---------+
+----+---------+
@end example
@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
For MyISAM and BDB tables you can specify @code{AUTO_INCREMENT} on
secondary column in a multi-column key. In this case the generated
secondary column in a multi-column key. In this case the generated
value for the autoincrement column is calculated as
value for the autoincrement column is calculated as
...
@@ -13694,6 +13702,7 @@ useful when you want to put data into ordered groups.
...
@@ -13694,6 +13702,7 @@ useful when you want to put data into ordered groups.
CREATE TABLE animals (
CREATE TABLE animals (
grp ENUM('fish','mammal','bird') NOT NULL,
grp ENUM('fish','mammal','bird') NOT NULL,
id MEDIUMINT NOT NULL AUTO_INCREMENT,
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (grp,id)
PRIMARY KEY (grp,id)
);
);
INSERT INTO animals (grp,name) VALUES("mammal","dog"),("mammal","cat"),
INSERT INTO animals (grp,name) VALUES("mammal","dog"),("mammal","cat"),
...
@@ -13716,9 +13725,6 @@ Which returns:
...
@@ -13716,9 +13725,6 @@ Which returns:
Note that in this case, the @code{AUTO_INCREMENT} value will be reused if you
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.
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
@node Batch mode, Twin, Examples, Tutorial
@section Using @code{mysql} in Batch Mode
@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