2

我不确定这是否是一个问题。我在我的一个应用程序上使用 simple.data。我检查了我表中的记录。我看到ID从1、2、3、4、5,跳到10002、10003 ... 10041,再跳到20018 ... 20028。

我注意到那些在同一天插入的记录,它们的 ID 仅增加 1。如果不是同一天,将增加 10000。

我在github上问了这个问题。确认这不是 Simple.Data 问题。更像是 sql server 问题。

这不会是 Simple.Data 正在做的任何事情。听起来可能存在复制设置,IDENTITY 范围每天分配新范围,或其他东西。但是 Simple.Data 根本不尝试生成 ID,所以问题出在其他地方。

如何检查身份范围?

我检查了身份规范:身份增量:1 身份种子:1

顺便说一句,ID 数据类型是 BigInt

4

1 回答 1

0

看起来你有一些工作(任务)通过在一天结束时添加 10000 来执行表的标识列的重新种子。这可以通过以下脚本(例如)来完成:

if object_id('tempdb..#t') is not null drop table #t
create table #t (id int identity(1,1), val int)

insert into #t select 1
insert into #t select 2
insert into #t select 3

select * from #t

dbcc checkident ('#t')
declare @x bigint
set @x = ident_current('#t')
select @x = floor((@x + 10000)/ 10000) * 10000
dbcc checkident ('#t', reseed, @x)

insert into #t select 1
insert into #t select 2
insert into #t select 3

select * from #t

上述查询的结果如下图所示:

在此处输入图像描述

于 2013-10-31T09:25:41.113 回答