简体   繁体   English

SQL Server ROWVERSION定义不正确吗?

[英]SQL server ROWVERSION definition is not accurate?

From msdn 来自msdn

Each database has a counter that is incremented for each insert or update operation that is performed on a table that contains a rowversion column within the database . 每个数据库都有一个计数器,该计数器针对在数据库中包含rowversion列的表执行的每个插入或更新操作递增。

Also

To return the current rowversion value for a database, use @@DBTS. 要返回数据库的当前rowversion值,请使用@@ DBTS。

I have a database ( believe me it has just one table and no timestamp / rowversion fields) 我有一个数据库(相信我只有一个表,没有时间戳/行版本字段)

在此处输入图片说明

But When I run select @@DBTS , I get a result as if I had a rowversion column : 但是当我运行select @@ DBTS时,我得到的结果就像是有一个rowversion列:

在此处输入图片说明

(ps - inserting / updating - doesn't update this value) . (ps-插入/更新-不更新此值)。

  • What is this value ? 这个值是多少?

  • Why Do I have it without having rowversion column ? 为什么没有rowversion列就拥有它?

What is this value ? 这个值是多少?

It's the value of the counter in the database that is used to implement rowversion columns. 它是用来实现在数据库中的计数器的值rowversion列。

Why Do I have it without having rowversion column ? 为什么没有rowversion列就拥有它?

The documentation you've quoted says that each database has such a counter. 您引用的文档说每个数据库都有一个计数器。 It then states that it will be incremented by operations against tables that contain rowversion columns. 然后声明将通过对包含rowversion列的表的操作来增加它。

It doesn't say that the existence of this counter depends on there being any such tables in your database. 这并不是说该计数器的存在 取决于数据库中是否存在任何此类表。


Parse it out as: 解析为:

A) Each database has a counter A)每个数据库都有一个计数器

B) that is incremented B)递增

C) for each insert or update operation that is performed C)对执行的每个插入或更新操作

D) on a table D)在桌子上

E) that contains a rowversion column E)包含rowversion列

F) within the database. F)在数据库内。

(E) and (F) are conditions that apply to (D). (E)和(F)是适用于(D)的条件。 (C) indicates what operations on (D) cause (B) to occur. (C)表示对(D)进行的哪些操作导致(B​​)发生。 None of (BF) affect the truth or otherwise of (A). (BF)均不影响(A)的真理。


There's also no documentation (that I can find) that indicates that it should start at 0x0000000000000000 or any other value. 也没有文档(我可以找到)来表明它应该以0x0000000000000000或任何其他值开头。 Given that the only purpose of this column is to allow ordering to be determined (X happened after Y or before Y), it shouldn't matter what the actual values returned are. 鉴于此列的唯一目的是确定顺序(X发生在Y之后或Y之前),所以返回的实际值是什么都不重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM