auto_increment columns only increment if they are passed a NULL value and work by adding 1 to the maximum value in the column. If you insert '234098' into the column and then use NULL values for inserting the rest of the records, the column will auto_increment starting at '234099'. | [reply] |
Yes, it is very simple, all you need to do is insert a
row into your table with the value 234097 explicitly stated
in your auto incrementing column, and then delete
the row. When you insert that row, it will update the
last_insert_id value to 234097. The next time you insert
a null value into that column, it will replace the null with
last_insert_id + 1 and then update last_insert_id, so it
should start counting up from 234098 as you requested.
| [reply] |
This is the way: but if it's important to have the min. value it's probably worth leaving the row instead of deleting it. IME, when one deletes the entire contents of the table, the auto_increment starts again from 1.
§ George Sherston
| [reply] |
Well, you could create a table in the DB which holds the last value for the auto-increment field.
Then, when you're adding the data, grab the value in that table and use it as your starting point for the incrementation. I'm assuming you're writing record by record here. When you're done writing your records, write the last used value back into the table so that you can use it next time.
-aijin. | [reply] |
| [reply] |