SQL Server 2012 column identity increment jumping from 6 to 1000+ on 7th entry(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:
- 使用跟踪标志 272 - 这将导致为每个生成的标识值生成日志记录.打开此跟踪标志可能会影响身份生成的性能.
- 使用带有 NO CACHE 设置的序列生成器 (http://msdn.microsoft.com/en-us/library/ff878091.aspx)
这篇关于SQL Server 2012 列标识增量在第 7 个条目时从 6 跃升至 1000+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 2012 列标识增量在第 7 个条目时从 6 跃升至 1000+


基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01