开发者

How to update existing AUTO NUMBER Values in MYSQL

I have created a MYSQL table with autoincrement id, and inserted appx 10K values, so now id starts from 1 onwards.

Now I 开发者_运维问答would like to change my existing ID from 10001 onwards.. i.e. my existing id 1 should starts from 10001..next 10002...

So how it possible without affect other data's

Thanks, Laxmilal Menaria


Try this:

UPDATE your_table
SET id = id + 10000


To "correct" old values do this:

UPDATE TABLE `tbl` SET `id` = `id` + 10000;

If you want all new autoincrementing values to start at 10001, do this (it will automatically skip numbers that are already set; so, if you already have 10001, it will start with 10002):

ALTER TABLE `tbl` AUTO_INCREMENT = 10000;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜