Reputation: 6409
I have a column in a table that is auto incremented. Let's call it employee_id
.
Let the initial value be 1 and let it be incremented by 1 for each insertion.
After inserting 10 rows, the auto incremented value becomes 10 (employee_id
is 10).
Now if I manually insert 11th row with an employee Id as 15 , and then allow MySql's AUTO_INCREMENT
to take over, will the next auto incremented value be 11 or 16 ?
Upvotes: 2
Views: 213
Reputation: 31
Next Auto_increament value will be 16. As Auto_increament will be updated after every insert/delete operation.
Upvotes: 0
Reputation: 566
It will be 16, bcs MySQL will update the value of AUTO_INCREMENT counter after each insert/update operation. This is for both most popular table engines, MyISAM and InnoDB:
Upvotes: 3
Reputation: 11586
I tried it on localhost and after inserting 15th row manually (employee_id=10, name=John
), it is going on by getting max auto_increment id
.
Storage Engine of table is: MyISAM.
Upvotes: 0