开发者

Optimistic Concurrency Issue and Improving Solutions

In our database we have gigantic tables (it was initially built 20 years ago). We are on the process of developing it.

Some tables contain rowversion and optimistic concurrency. We were wondering if there is a way to just correspond row开发者_如何学Pythonversion to the modification of some specific columns, but not all of them. In Normal Case, T-SQL which is generated then would be huge.

Any Suggestions?


What is the method it is using where rowversion is used for optimistic locking?

The standard trick is to read the rowversion when you read the row values. Later, when UPDATEing, you ensure that the rowversion in the database matches the rowversion when you last saw. If not, then you know someone else modified the row out of underneath you:

UPDATE Customers
SET Firstname = 'Faulty', Lastname = 'Orc', ...
WHERE CustomerID = 624429
AND rowversion = @rowversion

You only need to update the columns you want to update.

Is it that perhaps you want multiple people to independently make changes to the same row? In that case, no, you cannot do that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜