In the 4.0.17 and later build, the target table of an INSERT...SELECT can be
the same as the SELECT table (insert into table1...select ...from table1).
Does the process essentially happen in a natural lock? In other words,
could the table change between the data retrieved in the select and the time
the insert gets executed?
We used to use something like this:
Lock tables table1 write;
Select @a:=max(column) from table1;
Insert into table1 (column) values (@a+1);
Unlock tables;
Could that now be done as:
Insert into table1 (column) select max(column)+1 from table1;
-Allon
| Thread |
|---|
| • Is INSERT...SELECT atomic? | Allon Bendavid | 29 Jan |