Jump to content

Reset Auto_Increment Value


ainoy31

Recommended Posts

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 

 

Link to comment
https://forums.phpfreaks.com/topic/69368-reset-auto_increment-value/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.