|
最初由 ZALBB 发布
[B]jeffli73,请看看我的问题:
问:我说的那个意向锁,和你说的有差别吗?差别在哪里?
2、你如何理解ORACLE定义的7个级别的锁?为什么要这样定义? [/B]
看了你和jeffli73关于锁的对话,写得非常好,不过和oracle官方文章的描述还是有一定的差别,先摘录如下,供各位参考:
Lock Modes
Locks are applied to both compound and simple objects. The classic example of a compound object and its component parts is a table and its rows. A cache buffer is an example of a simple object. Simple objects may only be locked in the following modes:
Exclusive
If a session needs to modify a simple object, then an exclusive lock is
required on the resource to prevent any concurrent access.
Shared
If a session needs to inspect a simple object, then a shared lock on the
resource is sufficient to ensure that the data structure will not be modified by another session, while allowing concurrent shared access.
Null
If a session has some information cached about an object, then a null mode lock may be held as a placeholder, even when the resource is not actively being used. A null mode lock does not inhibit any concurrent access, but if the resource is invalidated, the null mode lock acts as a trigger for the session to invalidate its private cached information. There is an important difference between holding a null mode lock, and not holding a lock at all.
In addition to the modes above, compound objects may also be locked in the following modes:
Sub-shared
If a session needs shared access to part of a compound object, then a shared lock on the entire compound resource would be unduly restrictive, because it would prevent exclusive access to other parts of the compound resource. In such cases, a sub-shared lock is used instead.
Sub-exclusive
If a session needs exclusive access to part of a compound resource, then a sub-exclusive lock is sufficiently restrictive.
Shared-sub-exclusive
This lock mode is used when a session needs exclusive access to part of a compound resource and shared access to the entire compound resource at the same time. |
|