问题描述
我遇到了一个奇怪的情况,我的数据库中的某些表的 ID 从 0 开始,即使 TABLE CREATE 具有 IDENTITY(1,1).对于某些表是这样,但对于其他表则不然.它一直工作到今天.
我已经尝试重置身份列:
DBCC CHECKIDENT (SyncSession, reseed, 0);但是新记录从 0 开始.我已尝试对所有表执行此操作,但有些仍从 0 开始,有些仍从 1 开始.
有什么指点吗?
(我使用的是带有高级服务的 SQL Server Express 2005)
来自 DBCC CHECKIDENT
DBCC CHECKIDENT ( table_name, RESEED, new_reseed_value )<块引用>
如果没有插入行自创建以来的表,或所有已通过使用删除行TRUNCATE TABLE 语句,第一个运行 DBCC 后插入的行CHECKIDENT 使用 new_reseed_value 作为身份.否则,下一行插入使用 new_reseed_value +当前增量值.
因此,这是针对空表或截断表的预期.
I've got a strange situation with some tables in my database starting its IDs from 0, even though TABLE CREATE has IDENTITY(1,1). This is so for some tables, but not for others. It has worked until today.
I've tried resetting identity column:
DBCC CHECKIDENT (SyncSession, reseed, 0);
But new records start with 0. I have tried doing this for all tables, but some still start from 0 and some from 1.
Any pointers?
(i'm using SQL Server Express 2005 with Advanced Services)
From DBCC CHECKIDENT
DBCC CHECKIDENT ( table_name, RESEED, new_reseed_value )
If no rows have been inserted to the table since it was created, or all rows have been removed by using the TRUNCATE TABLE statement, the first row inserted after you run DBCC CHECKIDENT uses new_reseed_value as the identity. Otherwise, the next row inserted uses new_reseed_value + the current increment value.
So, this is expected for an empty or truncated table.
这篇关于SQL Server 标识列值从 0 而不是 1 开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)