访问数据库时实现读锁定。 [英] Implement read lock while accessing database.
问题描述
我们如何在数据库访问中实现读锁定。我有一个程序有4个实例,我想实现读锁,如:
- >当一个实例访问该表时,即使从表中读取也无法访问其他实例。
- >每个实例可以使用不同的事务,只有一个事务可以访问该表。 (在一个实例中只有一个交易)
- >只有在提交当前实例使用的事务后才能访问该表。
我这样做是使用ado.net。现在我正在使用
myTransaction = mySQLConnection-> BeginTransaction(System :: Data :: IsolationLevel :: Serializable);
这种隔离级别,但这将允许其他实例从表中读取,我想锁定甚至读取。我们怎样才能做到这一点。???这有可能吗?
Hi,
How we can achieve read lock in database access. I have a program with 4 instances of it, i want to implement read lock like:
-> when one instance access the table no other instance could not be accessed even for reading from the table.
-> Each instance can be used different transactions, only one transaction can have the access to the table. (only one transaction in one instance)
-> the table can be accessed only after committing the transaction used by the current instance.
I am doing this using ado.net. Now i am using
myTransaction = mySQLConnection->BeginTransaction(System::Data::IsolationLevel::Serializable);
this isolation level, but this will allow the other instances to read from the table, i wants to lock even the read. How can we achieve this.??? Is this possible in any way???
推荐答案
检查这个 control-sql-server-locking-with-hints / [ ^ ]
这篇关于访问数据库时实现读锁定。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!