php - How to resequence the AUTO_INCREMENT id in MySQL after deleting few records? -
i have table 3000 entries. randomly choosing 25 of shifted table. once done, want ids (which assigned auto_increment , primary key) in original table in sequence, perform next iteration. how should it?
we cannot change auto_increment value value other current max value.auto_increment counter keeps on incrementing value used column defined.
the other way change value above current max value manually alter value of auto_increment counter max(value) +1.
so guess here have order records in ascending existing id after deleting 25 records , manually set id value of each record according incrementing variable , in end set auto_increment count value value of variable in end +1.
sample :
alter table t set auto_increment=some_value;
though advised leave auto_increment alone , avoid if it's done sake of making ids great , there no other probable reason.
Comments
Post a Comment