0

Let's say I have a table with 3 rows of data, and I want to add an auto_increment column, I use the following syntax and it works

ALTER TABLE tableA ADD id BIGINT unsigned NOT NULL unique AUTO_INCREMENT

but the current rows will get the values like 1,2,3in the newly added auto_increment column.

I instead want those values to be say 1001,1002,1003. IS there a way to do that?

Note I do know that running

ALTER TABLE tableA AUTO_INCREMENT=1001

would work, but that only works for new rows, not for existing data

pvsk10
  • 261
  • 3
  • 6

1 Answers1

0

You can create the value with the auto increment keyword to specify a start number.

Alter table add column blah int(11) auto increment 10000;
Gregg Harrington
  • 123
  • 1
  • 11