定义一个自增列,使用delete后,再插入数据,自增列仍按照删除前的最大值递增;若使用truncate 后,再插入数据,自增列从头开始递增
脚本一(使用delete):
create table #test(codes int identity,valuess int)
insert into #test(valuess) select 1
select * from #test
----------------
delete from #test
------------------
insert into #test(valuess) select 2
select * from #test
drop table #test
脚本二(使用truncate):
create table #test(codes int identity,valuess int)
insert into #test(valuess) select 1
select * from #test
-------------------
truncate table #test
----------------------
insert into #test(valuess) select 2
select * from #test
drop table #test
时间: 2024-10-06 00:45:43