我没说清楚,不好意思。 id data 1 a 2 b 3 d 把后2个数据都删除后,再插入新数据,id将是4开始,请问怎么重新从1开始?
SET IDENTITY_INSERT table1 ON
create table table1(id int identity(1,1),data char(1)) insert into table1(data) select 'a' union select 'b' union select 'd' select * from table1 delete from table1 where id>1 go SET IDENTITY_INSERT table1 ON insert into table1(id,data) select 2,'e' union select 3,'f' go select * from table1 drop table table1;
id data
1 a
2 b
3 d
把后2个数据都删除后,再插入新数据,id将是4开始,请问怎么重新从1开始?
insert into table1(data)
select 'a'
union select 'b'
union select 'd'
select * from table1
delete from table1 where id>1
go
SET IDENTITY_INSERT table1 ON
insert into table1(id,data) select 2,'e' union select 3,'f'
go
select * from table1
drop table table1;