标签:
定义一个自增列,使用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
Sql Server自增列和delete truncate删除语句关系
标签:
原文地址:http://www.cnblogs.com/haoxiwang001/p/4623895.html