I think the answer to my question is obvious but since I could not find any documentation to support it, I thought it's worth asking. At least for the record.
As we all know AUTO_INCREMENT
fields are incremented each time an INSERT
statement is executed. And its value can be retrieved by LAST_INSERT_ID()
function. It is also mentioned in MySQL's Manual that with multiple-row inserts, LAST_INSERT_ID()
will return the first ID of the inserted rows. Which I think is a good idea (really useful).
So here goes my question:
Can I assume in an INSERT IGNORE INTO
statement with multiple-rows, the inserted IDs of an AUTO_INCREMENT
field will always be sequential? Keep in mind that due to IGNORE
modifier and the multi-user nature of MySQL server, different scenarios might happen.
Thanks.
IGNORE
modifier, do the duplicate rows advance the counter even though they are inserted? I ask this because I've seen that in single rowINSERT
statements withoutIGNORE
modifier, the counter is incremented when some error happens, even though the row is not inserted! – Soubise