cliftonbazaar Posted April 10, 2009 Share Posted April 10, 2009 At the moment I am testing my database and inserting and deleting records, this pushes the auto-increment number through the roof. When I have finished testing is there a way of resetting this? Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/ Share on other sites More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 Truncate or drop your table Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/#findComment-806861 Share on other sites More sharing options...
Maq Posted April 10, 2009 Share Posted April 10, 2009 I found this reply for a similar problem on MySQL, In order to reset the auto_increment, in a situation where some of the most recently added rows were deleted, use: ALTER TABLE theTableInQuestion AUTO_INCREMENT=1234 and future insertions will be numbered from 1234 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ). http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html Hope this helps. Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/#findComment-806863 Share on other sites More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 Wow - didn't know you could do that. Tis pretty useful. Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/#findComment-806866 Share on other sites More sharing options...
Maq Posted April 10, 2009 Share Posted April 10, 2009 Wow - didn't know you could do that. Tis pretty useful. Me either, just found it on Google. As far as helpfulness, I've never actually needed to do something like this. But I could see how such large numbers could get annoying. Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/#findComment-806871 Share on other sites More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 I agree. Oddly, my users table suddenly started incrementing from 60,000 one day, so I tried changing user's IDs back to their proper value but new users still incremented from 60,000. I think I shall try this Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/#findComment-806887 Share on other sites More sharing options...
cliftonbazaar Posted April 10, 2009 Author Share Posted April 10, 2009 Thanks for all the replies; just about to reset it now Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/#findComment-806898 Share on other sites More sharing options...
Maq Posted April 13, 2009 Share Posted April 13, 2009 I agree. Oddly, my users table suddenly started incrementing from 60,000 one day, so I tried changing user's IDs back to their proper value but new users still incremented from 60,000. I think I shall try this Yes, it's meant to do this to retain its "uniqueness". But ALTERing the table this way, should work. Link to comment https://forums.phpfreaks.com/topic/153553-solved-resetting-auto-increment-in-database/#findComment-808551 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.