anon Posted January 1, 2008 Share Posted January 1, 2008 I have a table with auto-increment. When i delete all data in the database, and then enter a new value, the id won't return to 1, it will auto-increment after the last deleted value. e.g the new values id will be 5, not 1. How do i get it to reset? Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/ Share on other sites More sharing options...
toplay Posted January 1, 2008 Share Posted January 1, 2008 It's in the manual: To change the value of the AUTO_INCREMENT counter to be used for new rows, do this: ALTER TABLE t2 AUTO_INCREMENT = value; Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-427305 Share on other sites More sharing options...
revraz Posted January 1, 2008 Share Posted January 1, 2008 If you have PHPMyAdmin, you can do it in there as well. Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-427308 Share on other sites More sharing options...
anon Posted January 1, 2008 Author Share Posted January 1, 2008 How do i do that in phpmyadmin? Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-427327 Share on other sites More sharing options...
fenway Posted January 1, 2008 Share Posted January 1, 2008 If you really want to empty a table, use TRUNCATE, and you won't have this problem. Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-427358 Share on other sites More sharing options...
anon Posted January 1, 2008 Author Share Posted January 1, 2008 I don't want to just empty the table, i want it to reset back to 1 afterwards. Doesn't do that, carries on counting after I have deleted the entire table. Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-427362 Share on other sites More sharing options...
revraz Posted January 1, 2008 Share Posted January 1, 2008 Under the Table, go to Operations. You can set it there. How do i do that in phpmyadmin? Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-427366 Share on other sites More sharing options...
fenway Posted January 2, 2008 Share Posted January 2, 2008 I don't want to just empty the table, i want it to reset back to 1 afterwards. Doesn't do that, carries on counting after I have deleted the entire table. You deleted the entire table, but you don't want to empty it? What does that mean? TRUNCATE deletes and resets the counter properly. Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-428134 Share on other sites More sharing options...
anon Posted January 2, 2008 Author Share Posted January 2, 2008 (not being smarmy here) I said I don't just want it to delete.... I want it to delete the entire table AND reset counter I understand that Truncate does that now. Quote Link to comment https://forums.phpfreaks.com/topic/83971-solved-mysql-table-back-to-1-after-delete/#findComment-428515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.