Changing/Altering the Auto_increment value - Mysql Views : 712
Tagged in : Mysql
0 0
Send mail
Some times we tend to test tables by inserting and deleting rows.
If we have an auto_increment column in the table then even after deleting the auto_increment value would continue to increase.

For example

if we had 5 rows and then deleted those 5.

After this if we tend to insert a new row the value of the auto_increment column would '6',but we would like to have '1'.

So if we want to start the value again from 1 , use the following query:

alter table <table_name> auto_increment=<value>;

ex:
alter table xx auto_increment=10;

After the execution of the above query the next insertion would have the value as '10'.
By Vijay, On - 2008-03-14



    Login to add Comments .