To reset the AUTO_INCREMENT counter in MySQL, use ALTER TABLE table_name AUTO_INCREMENT = N; where N is the next integer value you want assigned to the next inserted row. Note that MySQL generally will not set AUTO_INCREMENT lower than the current maximum value stored in the column (MAX(id) + 1), and TRUNCATE TABLE resets the counter back to 1 automatically.
1. Set a Specific Next Value with ALTER TABLE
Use ALTER TABLE to advance the counter (for example, after deleting high-ID test rows or reserving an ID range):
ALTER TABLE orders AUTO_INCREMENT = 1001;
You must log in or register to comment.
