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.
精彩评论