简体   繁体   English

使用 MAX(rowversion) 作为全表数据更改指示器可靠吗?

[英]Is reliable to use MAX(rowversion) as table wide data change indicator?

In this application we have this users table that do not gets updated so frequently and we're planning cache this data in the client.在这个应用程序中,我们有一个不会如此频繁更新的用户表,我们计划在客户端缓存这些数据。

Is reliable to use the MAX(rowversion) value as an indicator of data changes in that particular table?使用MAX(rowversion)值作为该特定表中数据更改的指标是否可靠?

DECLARE @latestChange TIMESTAMP = 0x0000000000030D45
IF  EXISTS  (
    SELECT  TOP (1) 1
    FROM    MyTable
    HAVING  MAX(Version) <> @latestChange ) BEGIN

    SELECT  'Table has been changed, do stuff'
END

Not in general.一般不会。 If a row is deleted, the whole row, including the rowversion column is gone.如果删除一行,则整行,包括 rowversion 列都将消失。 Change Tracking will do this for you, without the need for a rowversion column. 更改跟踪将为您完成此操作,而无需 rowversion 列。

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

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