Home > Database > Mysql Tutorial > SQL Server 不删除信息重新恢复自动编号列的序号的方法

SQL Server 不删除信息重新恢复自动编号列的序号的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:57:18
Original
1018 people have browsed it

SQL Server 不删除信息重新恢复自动编号列的序号的方法

在sql server中经常有这样的问题:
一个表采用了自动编号的列之后,由于测试了好多数据,自动编号已累计了上万个。现在正是要用这个表了,测试数据已经删了,遗留下来的问题 就是 在录入新的数据,编号只会继续增加,已使用过的但已删除的编号就不能用了, 谁知道如何解决此问题?

truncate命令不但会清除所有的数据,还会将IDENTITY的SEED的值恢复到原是值。

而DBCC CHECKIDENT则更加方便一些,可以在不删除数据的情况下指定SEED的值。
1. truncate table tablename
2. DBCC CHECKIDENT (tablename,reseed,1)
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template