MySQL Add x to current Primary Key value -


i have database contains primary key, boss wants me renumber (current pk value) + 800000...

so, pk 1 become 800001, pk 2354 come 802354 etc...

is there simple way or should write script?

probably straightforward way drop primary key table (not column, index), update values increase 800000, , add primary key column again.

alter table rptapp_batches change column id id int not null; alter table rptapp_batches drop primary key; update rptapp_batches set id = id + 800000; alter table rptapp_batches add primary key (id); alter table rptapp_batches change column id id int auto_increment; 

the first , last statements needed if pk auto_increment.


Comments