Mr Yar Mr Yar - 9 months ago 27
MySQL Question

how can i change the start id number in mysql

I would like to change the initial number of id from 1 to 2000.
My table :

id value type
1 e photo
2 f text
3 g photo


and here is what i want as result:

id value type
2001 e photo
2002 f text
2003 g photo

Gab Gab
Answer Source

Here is the query to change the auto increment value in your table:

ALTER TABLE my_table AUTO_INCREMENT=2000;

If you just want to add 2000 to all the IDs you can do:

UPDATE my_table SET id = id + 2000;

But its not very clean to do that.