为什么我的 IDENTITY 列值存在差距?

2021-12-02 00:00:00 sql sql-server

我有问题.

我的主 ID (IDENTITY) 配置为自动递增(类型:int).但是,当我插入新行时,这个新 id 不是连续的.怎么了?有什么解决办法吗?

My ID Primary (IDENTITY) is configure to auto-increment (type: int). But, when I insert a new row, this new id is not consecutive. What is happening? Any solutions?

[...]
[id]int] IDENTITY(1,1) NOT NULL,
[...]
CONTRAINT [PK_Medida] PRIMARY KEY CLUSTERED
(
[id] ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

推荐答案

不要期望标识是连续的.有许多场景可能会留下空白.将身份视为一个抽象的数字,不要为其附加任何商业意义.

Do not expect the identities to be consecutive. There are many scenarios that can leave gaps. Consider the identity like an abstract number and do not attach any business meaning to it.

相关文章