MySQL Forums
Forum List  »  General

Order of rows on inserting multiple rows
Posted by: Андрей Щербаков
Date: December 10, 2018 08:24AM

I have table with AUTO_INCREMENT column. Now I insert multiple rows with one INSERT.

CREATE TABLE animals (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (id)
);

INSERT INTO animals (name) VALUES
('dog'),('cat'),('penguin'),
('lax'),('whale'),('ostrich');

Is it truth that rows get AUTO_INCREMENT value in order they are specified in query? Can I rely on this behaviour in my code to map new ids to values i inserted?

I haven't found implicit answer on this question in documentation..

Options: ReplyQuote


Subject
Written By
Posted
Order of rows on inserting multiple rows
December 10, 2018 08:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.