34,587
社区成员
发帖
与我相关
我的任务
分享
create table zd
(id int identity(1,1) not null,
name varchar(10)
constraint pk_zd primary key (id)
)
insert into zd(name)
select 'aa' union all
select 'bb' union all
select 'cc'
select * from zd
/*
id name
----------- ----------
1 aa
2 bb
3 cc
(3 row(s) affected)
*/
-- 把第三行删除
delete from zd where id=3
-- 再添加数据,id=3
set identity_insert zd on
insert into zd(id,name)
select 3,'cc2'
set identity_insert zd off
-- 结果
select * from zd
/*
id name
----------- ----------
1 aa
2 bb
3 cc2
(3 row(s) affected)
*/