I want to apply data concurrency on some of tables in my SQL Server database. In order to achieve row versioning, I am thinking of adding an integer
column named RowVersion
, and increase the row value of the column when I update a row.
我想在SQL Server数据库中的一些表上应用数据并发性。为了实现行版本控制,我正在考虑添加一个名为RowVersion的整数列,并在更新一行时增加列的行值。
There is an other option: using timestamp
column. When you use timestamp
column, SQL Server automatically creates a unique value when the row was updated.
还有一个选项:使用时间戳列。当使用时间戳列时,SQL Server在更新行时自动创建惟一值。
I want to know the advantages of these options. I think that inserting an int
column to store row version is more generic way while inserting a timestamp
column is SQL Server specific.
我想知道这些选择的好处。我认为插入一个int列来存储row版本是更通用的方式,而插入timestamp列是SQL Server特有的。
What is more, integer
value of a row version is more human readable than timestamp
column.
此外,行版本的整数值比时间戳列更容易读懂。
I want to know other advantages or disadvantages choosing integer
column for row version field.
我想知道为行版本字段选择整列的其他优点或缺点。
Thanks.
谢谢。
1 个解决方案
#1
5
If you let SQL server do it for you, you have guaranteed atomicity for free. (Concurrent updates on the same table are guaranteed to produce different row versions.) If you roll your own row versioning scheme, you are going to have to do whatever it takes to guarantee atomicity by yourself.
如果您让SQL server为您做这件事,您就可以免费保证原子性。(同一表上的并发更新保证会产生不同的行版本。)如果您使用自己的行版本控制方案,您将不得不自己做任何事情来保证原子性。
#1
5
If you let SQL server do it for you, you have guaranteed atomicity for free. (Concurrent updates on the same table are guaranteed to produce different row versions.) If you roll your own row versioning scheme, you are going to have to do whatever it takes to guarantee atomicity by yourself.
如果您让SQL server为您做这件事,您就可以免费保证原子性。(同一表上的并发更新保证会产生不同的行版本。)如果您使用自己的行版本控制方案,您将不得不自己做任何事情来保证原子性。