SELECT MAX(ai_col) FROM table_name FOR UPDATE Īccording to the source code, for statements like INSERT INTO. To initialize an auto-increment counterĪfter a server restart, InnoDB would execute the equivalent of theįollowing statement on the first insert into a table containing an In MySQL 5.7 and earlier, the auto-increment counter is stored only in ![]() But when you restart the MySQL server, your next auto_increment id will be 1001. The next auto_increment value will be 51. Say your current auto_increment value on a table is 50 and you also have an id of 1000 in your table.Required by each statement may not be known and overestimation is Only if there are concurrently executing “INSERT-like” statements.įor lock modes 1 or 2, gaps may occur between successive statementsīecause for bulk inserts the exact number of auto-increment values Gaps in the auto-increment values generated by “bulk inserts,” but ![]() With innodb_autoinc_lock_mode set to 2 (“interleaved”), there may be Statement are consecutive, without gaps, because the table-levelĪUTO-INC lock is held until the end of the statement, and only one (“consecutive”), the auto-increment values generated by any given With innodb_autoinc_lock_mode set to 0 (“traditional”) or 1 Set innodb_autoinc_lock_mode=0 to ensure statements are run in order. In this case single INSERT statements and bulk INSERT statements could be run through each other.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |