My auto-incrementing primary keys are getting too high.
I’d like to reset it.
1, 2, 3, 4, 5, 6.
If I reset it to 0, the next inserted row will be 7, right?
How do I reset the autoincrement?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I agree with Lutz, it’s not a good idea to change the auto-increment ID. The primary key is important for data integrity and even if you don’t have any dependencies to other tables, it’s better not to get used fiddling with it.
If you have public facing IDs (e.g. on a web site) that become too high, introduce an alternative column for those.
But to answer the question:
ALTER TABLE theTableInQuestion AUTO_INCREMENT=1234See the docs on AUTO_INCREMENT on details.