summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <arjen@fred.bitbike.com>2002-07-12 13:35:52 +1000
committerunknown <arjen@fred.bitbike.com>2002-07-12 13:35:52 +1000
commit7d3213151534e6486fbc9cd5f17768d39ee0850d (patch)
tree7a9ff0d633bcbfa4a87c06973dd6b14debf1548e
parente81b43ebe37e51725cda72671c09cc6afee78dcf (diff)
downloadmariadb-git-7d3213151534e6486fbc9cd5f17768d39ee0850d.tar.gz
Clarified LAST_INSERT_ID() behaviour for multi-row inserts.
Shuffled lines for easier reading. Added missing SQL line.
-rw-r--r--Docs/manual.texi12
1 files changed, 9 insertions, 3 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 0f662b779fe..74c9d7ddb72 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -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