Details
I couldn't find any info regarding this issue on SE or MySQL docs.
I have encountered a situation where I may need to insert an auto-inc value higher than the current value. For example, the auto-inc column is currently at 12 & I need to insert a row with the auto-inc field at 15.
Questions
1 - If I was to simply just do this insert, would it clash once the auto-inc hits 15 or would the next value inserted start at 16? I was told the latter is how it works by a friend. However, in the docs I came across a statement that it would cause it to clash later on. Would I have to reseed the table to 16 after doing this?
2 - What is a best practice in a situation like this?
Please, let me know if any other information should be provided.
As far as I know, inserting a value higher than the current increment has the effect of adjusting the AUTO_INCREMENT
value in your database. That is, inserting 20 will set it to 21. I'm fairly certain this behaviour is consistent in newer versions of MySQL.
You can see the current increment with SHOW CREATE TABLE
.