ainoy31 Posted September 14, 2007 Share Posted September 14, 2007 Hello- I want to know if it is safe to run the following script to reset my auto increment value in my table without messing up the current records? ALTER TABLE carriers_schedule AUTO_INCREMENT = 1 I have a script that automatically delete records if it is older than today when an upload occurs. Right now I have up to 9756 records but an estimated 1 - 2545 records already have been deleted. I want the to count to start over at 1 after it reaches say 1200. Much appreciation Quote Link to comment https://forums.phpfreaks.com/topic/69368-reset-auto_increment-value/ Share on other sites More sharing options...
leafface Posted September 14, 2007 Share Posted September 14, 2007 Well, since that script only sets the ID for the upcoming records, the current records stay untouched. The only harm in this could be ID duplication, when a daily upload runs over 1200, but i suppose you're aware of that. Quote Link to comment https://forums.phpfreaks.com/topic/69368-reset-auto_increment-value/#findComment-348684 Share on other sites More sharing options...
effigy Posted September 15, 2007 Share Posted September 15, 2007 Save yourself the trouble and increase the size of the id's data type. Quote Link to comment https://forums.phpfreaks.com/topic/69368-reset-auto_increment-value/#findComment-348818 Share on other sites More sharing options...
fenway Posted September 15, 2007 Share Posted September 15, 2007 Well, since that script only sets the ID for the upcoming records, the current records stay untouched. The only harm in this could be ID duplication, when a daily upload runs over 1200, but i suppose you're aware of that. Agreed... don't reset IDs, unless you blow away all of the data in the table, in which case use TRUNCATE, not DELETE. Quote Link to comment https://forums.phpfreaks.com/topic/69368-reset-auto_increment-value/#findComment-349040 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.