问题
while the development of websites we use the database to test & all... which consumes a lot from auto generated (auto increment) attributes series... how to reset everything...
回答1:
Assuming you're deleting the records when you're done testing, a TRUNCATE
command will delete all records and reset the autoincrement value.
回答2:
ALTER TABLE _TABLE_ AUTO_INCREMENT=1
回答3:
Another possibility, avoiding transactions and resetting the autoincrement counter could be to combine the select to get the next available id and the insert itself;
INSERT INTO tablename (id, somefield1, somefield2) SELECT max(id)+1, 'test', 5 FROM tablename
来源:https://stackoverflow.com/questions/4246959/mysql-database-reset-autoincrement-fields