How to reset AUTO_INCREMENT in MySQL?
How to reset AUTO_INCREMENT in MySQL?
464
12-Apr-2023
Updated on 13-Apr-2023
Krishnapriya Rajeev
13-Apr-2023To reset the auto_increment value in MySQL, you can use the ALTER TABLE statement with the AUTO_INCREMENT option. Given below is an example:
Let's say you have a table named my_table with an auto_increment column named id. If you want to reset the auto_increment value to start from 1 again, you can use the following SQL statement:
This will set the auto_increment value for the id column to 1, and the next inserted row will have an id value of 1.
If you want to set the auto_increment value to a specific number other than 1, you can replace "1" in the above statement with the desired starting value.