Hello friends, I was facing issue in database. I wanted the auto increment should start from 1.
There were 20 rows in table. When I deleted all the rows from the table and inserted new row then auto increment started from id = 21 instead of 1. I wanted to start counting from 1 again. This issue was resolved by following lines :
ALTER TABLE tablename AUTO_INCREMENT = 1
For InnoDB you cannot set the auto_increment
value lower or equal to the highest current index.
This is the sample example: Here you can see that I am deleting records from table user_invites having 5 rows in it.

5 rows have been deleted as shown below:

Now I inserted one row into the table user_invites:

Now you will see that instead of starting from id 1, it is starting from id 27

Now lets reset auto increment

Now lets insert 1 row again

Now you will see that auto increment has been reset to 1

Thanks for reading the blog.
0 Comment(s)