Reindex MySql table

I have a MySql table with an auto-increment id field, and in the table I have 4 records that do not change and have ids 1 to 10. The table also contain another 20+ records with id's eg 11-31. The last 20 records will be regularly deleted and re-iniserted with slightly different data, is there anyway of resetting the autoincrement back to the last record id+1, using Php without creating a new table?
LVL 1
ncwAsked:
Who is Participating?
 
ncwAuthor Commented:
This option from your link could be usefull:

ALTER TABLE tbl AUTO_INCREMENT = 100;
0
 
Lukasz ChmielewskiCommented:
Should reset the autoincrement

    $q = "alter table test AUTO_INCREMENT = 2";
    $r = mysql_query($q);
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
johanntagleCommented:
Deleted and reinserted with slightly different data?  So why not just update the rows instead of all that trouble?
0
 
ncwAuthor Commented:
Deleting and reinserting data causes the id to start at the next auto-incremented id unless you recreate the table or alter the auto-increment start value, as far as I know.
0
 
johanntagleCommented:
Deleting and reinserting data causes the id to start at the next auto-incremented id unless you recreate the table or alter the auto-increment start value, as far as I know.

Exactly.  My point is, why delete and reinsert at all when you can just update the rows to reflect the slightly different data?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.