What's the difference between an exclusive lock and a shared lock?

前端 未结 4 1352
终归单人心
终归单人心 2021-01-29 17:08

According to wikipedia,

Shared locks are sometimes called \"read locks\" and exclusive locks are sometimes called \"write locks\".

4条回答
  •  面向向阳花
    2021-01-29 17:47

    Principle same on the database side as well. As per the Oracle documentation

    Exclusive lock mode prevents the associated resource from being shared. This lock mode is obtained to modify data. The first transaction to lock a resource exclusively is the only transaction that can alter the resource until the exclusive lock is released.

    Share lock mode allows the associated resource to be shared, depending on the operations involved. Multiple users reading data can share the data, holding share locks to prevent concurrent access by a writer (who needs an exclusive lock). Several transactions can
    acquire share locks on the same resource.

提交回复
热议问题