Changing the current count of an Auto Increment value in MySQL?

Viewed 49040

Currently every time I add an entry to my database, the auto increment value increments by 1, as it should. However, it is only at a count of 47. So, if I add a new entry, it will be 48, and then another it will be 49 etc.

I want to change what the current Auto Increment counter is at. I.e. I want to change it from 47 to say, 10000, so that the next value entered, will be 10001. How do I do that?

4 Answers

you can get that done by executing the following statement

ALTER TABLE t2 AUTO_INCREMENT = 10000;

So next Auto Increment key will start from the 10001.

I hope this will solve the problem

You can also set it with the table creation statement as follows;

CREATE TABLE mytable (
     id int NOT NULL AUTO_INCREMENT,
     ...
     PRIMARY KEY (ID)
)AUTO_INCREMENT=10000;

Hope it helps someone.

Related