mysql - How do I set auto increment field values to higher numbers? -
i have column called num
in sql have auto incremented 1. know can start sequence value using:
alter table [mydatabase].[dbo].[mytable] auto_increment=500
now of records there. possible increase num
values? without deleting records?
you can't update identity column can move data location, delete original data set identity_insert on , move data updated incrimentor.
set nocount on -- create table test create table #mytable ( id int identity(1,1), data int ) insert #mytable ( data ) values ( 10 ) insert #mytable ( data ) values ( 20 ) insert #mytable ( data ) values ( 30 ) -- store data in temp location select * #templocation #mytable -- delete original data delete #mytable -- insert updated id set identity_insert #mytable on insert #mytable ( id, data ) select id + 500, data #templocation set identity_insert #mytable off
Comments
Post a Comment