Suppose I have a table with an auto_increment column, and then insert multiple values in a single statement:
insert into foo (bar) values ('a'), ('b'), ('c');
From the documentation, last_insert_id()
returns the first generated ID for the query, the ID for a
in this case.
Does mysql give any guarantees that a b
and c
will then be assigned sequential values?
In other words, if last_insert_id() returns 1 for a
, is there any guarantee that b = 2 and c = 3? Or could there be a scenario where due to multiple concurrent inserts, I could end up with something like "a = 1, b = 5, c = 9"?