Change the auto increment value in MySQL

Change the auto increment column in Mysql

We can change the value of auto increment column which set by getting the maximum value from the table. Suppose we did lot of delete operation and we want to set the auto increment again but we need to fine first max value present in table then we change it.

Find the max value for the column

select max(column_name) from table_name;

Set the Auto increment value for the table, suppose max return 100 then plus 1 for new value.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.