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?

Oletem
  • 19
  • 1
  • 11

2 Answers2

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.

Shadow
  • 33,525
  • 10
  • 51
  • 64
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?

Mohammad Anas
  • 320
  • 3
  • 6