i am a new comer to the entire database scenario and merely learning. I've got a database mysql and i'm using phpmyadmin to edit fields etc. I produced a auto_incremenet 'id' area that's set like a primary. Basically add 5 fields, the id is going to be '1,2,3,4,5'. Basically remove all individuals fields and add another 5 fields, how come the ID visit '6,7,8,9,10'? (rather than returning to , since technically another fields don't exist any longer so its right?). It is possible to method to result in the id be sequentially number? 1,2,3,4,5 ?

You don't have to be worried about it. Most of your key ought to be an unsigned int which could hold big enough amounts.

In my opinion this occurs because when utilizing a relational database system, you are able to "link" rows with other rows, usually by their id. Should you start re-using IDs, then you definitely might finish up in confusing situations.

You are able to totally reset the car_increment counter to whatever you want while using following query:


If you're removing all rows inside your table, you should use TRUNCATE that will also totally reset the counter.


I believe the primary reason behind this behavior is efficiency, this means that MySQL does not have to track which amounts aren't used, it only have to know which number was last used.

Take a look at this question. But essentially:



As pointed out, fiddling with auto produced PKs will indefinitely cause you plenty of headache. Or writing a lot of boilerplate code to complete housekeeping.

You'll have to totally reset the car increment, so that you can renumber the carincremented values, find out more concerning the solutions here http://www.dbuggr.com/milly/reset-auto-increment-mysql/.