SQL Server 2012 列标识增量在第 7 个条目上从 6 跳到 1000+ [英] SQL Server 2012 column identity increment jumping from 6 to 1000+ on 7th entry

查看:38
本文介绍了SQL Server 2012 列标识增量在第 7 个条目上从 6 跳到 1000+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的场景,我的 SQL Server 2012 数据库中的 auto identity int 列没有正确递增.

I have a strange scenario in which the auto identity int column in my SQL Server 2012 database is not incrementing properly.

假设我有一个使用 int 自动标识作为主键的表,它偶尔会跳过增量,例如:

Say I have a table which uses an int auto identity as a primary key it is sporadically skipping increments, for example:

1,2、3、4、5、1004,1005

1, 2, 3, 4, 5, 1004, 1005

这是在非常随机的时间随机数量的表上发生的,无法复制它以找到任何趋势.

This is happening on a random number of tables at very random times, can not replicate it to find any trends.

这是怎么回事?有没有办法让它停止?

How is this happening? Is there a way to make it stop?

推荐答案

这一切都很正常.Microsoft 在 SQL Server 2012 中添加了 sequences,最后,我可能会添加和更改身份密钥的生成方式.看看这里 一些解释.

This is all perfectly normal. Microsoft added sequences in SQL Server 2012, finally, i might add and changed the way identity keys are generated. Have a look here for some explanation.

如果你想拥有旧的行为,你可以:

If you want to have the old behaviour, you can:

  1. 使用跟踪标志 272 - 这将导致为每个生成的标识值生成日志记录.打开此跟踪标志可能会影响身份生成的性能.
  2. 使用具有 NO CACHE 设置的序列生成器 (http://msdn.microsoft.com/en-us/library/ff878091.aspx)

这篇关于SQL Server 2012 列标识增量在第 7 个条目上从 6 跳到 1000+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆