create table tb(id bigint identity(321256588,1),ic int) insert into tb select 1 union all select 2 goselect * from tbdrop table tb/*************id ic -------------------- ----------- 321256588 1 321256589 2(2 行受影响)
先增加一条记录 --注意必须指定种子列的列名,如下例中的id必须要列出 SET IDENTITY_INSERT tb ON INSERT tb(id,col) VALUES(321256588,11) SET IDENTITY_INSERT tb OFF 再删除此条记录,后面新添加记录时自动从321256588开始
create table tb(id bigint identity(1,1),ic int) insert into tb select 1 union all select 2 goselect * from tb/* id ic -------------------- ----------- 1 1 2 2 */set identity_insert tb on insert into tb(id,ic) values(321256588,3) set identity_insert tb offselect * from tb/* id ic -------------------- ----------- 1 1 2 2 321256588 3 */delete from tb where id = 321256588select * from tb/* id ic -------------------- ----------- 1 1 2 2 */insert into tb select 5select * from tb/* id ic -------------------- ----------- 1 1 2 2 321256589 5 */drop table tb
create table tb(id bigint identity(321256588,1),ic int)
insert into tb
select 1 union all
select 2
goselect *
from tbdrop table tb/*************id ic
-------------------- -----------
321256588 1
321256589 2(2 行受影响)
--注意必须指定种子列的列名,如下例中的id必须要列出
SET IDENTITY_INSERT tb ON
INSERT tb(id,col) VALUES(321256588,11)
SET IDENTITY_INSERT tb OFF 再删除此条记录,后面新添加记录时自动从321256588开始
create table tb(id bigint identity(1,1),ic int)
insert into tb
select 1 union all
select 2
goselect *
from tb/*
id ic
-------------------- -----------
1 1
2 2
*/set identity_insert tb on
insert into tb(id,ic) values(321256588,3)
set identity_insert tb offselect *
from tb/*
id ic
-------------------- -----------
1 1
2 2
321256588 3
*/delete from tb where id = 321256588select *
from tb/*
id ic
-------------------- -----------
1 1
2 2
*/insert into tb
select 5select *
from tb/*
id ic
-------------------- -----------
1 1
2 2
321256589 5
*/drop table tb