当前位置: 动力学知识库 > 问答 > 编程问答 >

php - inserting a row into a table and bumping up the auto increment values that come after

问题描述:

I tried to find out the correct way to do this via googling but I am not finding anything helpful.

I am wanting to insert a row before id 60 and id is an auto incrementing value. In the end I want to have all the values of id to be bumped up by 1 so there isn't a collision on the primary key of id.

网友答案:

Try this::

Step1:

update table set id=id+1 where id>=60

Step2:

Insert into table(id, column1....) values (60,....)
分享给朋友:
您可能感兴趣的文章:
随机阅读: