1

First, I create column img_ids, which I want to increment later on, with initial value 393.

Next step, I do the following:

Alter table img_ids_for_media modify image_id int(11) AUTO_INCREMENT PRIMARY KEY

This gives me simple incrementation 1,2,3...

After this I try:

 Alter table img_ids_for_media  AUTO_INCREMENT = 393

This query passes, but does not do anything at all. I still have 1,2,3, not

393,393,394

What can I do with this?

2 Answers 2

2

The problem is that changing the auto_increment value for a table sets the next auto_increment value to be used, it does not affect existing values within the field - rightly so.

What you can do is update the existing auto_increment values by adding 392 to them (image_id=image_id+392).

Then make sure you set the next auto_increment value to max(image_id)+1.

Sign up to request clarification or add additional context in comments.

Comments

0

It is already answered under How to set initial value and auto increment in MySQL?

Check this link

How to set initial value and auto increment in MySQL?

1 Comment

That's what exactly the OP did and ended up having this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.