Changing/Altering the Auto_increment value

by Vijay 2008-03-14 18:44:18

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'.

Tagged in:

1809
like
0
dislike
0
mail
flag

You must LOGIN to add comments