You can reset the AUTO_INCREMENT value in MySQL either by using a SQL command or by using phpMyAdmin.
NOTE: You cannot reset the counter to a value less than or equal to the value that is currently in use. For both InnoDB and MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum AUTO_INCREMENT column value plus one.
To reset the Primary Key Value to 1, you should either delete the table and create a new table or TRUNCATE the table and apply the command below. But DON'T do this, if you already have data in your table.
1. Using SQL Command:
where,
- table_name is the name of the table whose AUTO_INCREMENT value you want to reset.
2. Using phpMyAdmin Operation:
- First open the table whose AUTO_INCREMENT value you would like to reset.
- Once inside the table click on the Operation tabs as shown in the image below.
3. To save the changes you've made, click on Go.
NOTE: You cannot reset the counter to a value less than or equal to the value that is currently in use. For both InnoDB and MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum AUTO_INCREMENT column value plus one.
To reset the Primary Key Value to 1, you should either delete the table and create a new table or TRUNCATE the table and apply the command below. But DON'T do this, if you already have data in your table.
1. Using SQL Command:
ALTER TABLE table_name AUTO_INCREMENT =1;
where,
- table_name is the name of the table whose AUTO_INCREMENT value you want to reset.
2. Using phpMyAdmin Operation:
- First open the table whose AUTO_INCREMENT value you would like to reset.
- Once inside the table click on the Operation tabs as shown in the image below.
Click on image to enlarge |
3. To save the changes you've made, click on Go.
No comments:
Post a Comment
Thank you for your Feedback!
www.evagabond.me