What is the difference between an explicit and an implicit lock in database?
Implicit locks are generally placed by the DBMS automatically. Most DBMS allow the developer or the application to issue locks which are referred to as explicit locks.
Implicit Locking
Objectivity/DB will implicitly obtain the appropriate locks for your application at the point at which they are needed. An operation that reads an object will obtain a read lock; an operation that modifies an object will obtain a write lock.
Explicit Locking
Implicit locking obtains access rights to resources as they are needed by an application. In general, the automatic locking by Objectivity/DB provides a level of federated database concurrency that is sufficient for most applications.
Some applications, however, may need to reserve access to all required resources in advance. Reasons for doing so might be to secure required access rights to the necessary objects before beginning an operation, or to prevent other sessions from modifying objects critical to the operation.
An application needing to reserve access to all required objects in advance can explicitly lock objects. Suppose an application needs to calculate a value based upon the state of many objects at a specific point in time. Although the application cannot check all of the necessary objects simultaneously, it can achieve the same effect by freezing the state of the objects and then checking them in sequence. Explicit locking effectively freezes the objects, because no other session can modify them as long as they are locked.
- Explicit Lock: - Lock is explicitly requested for a record or table.
- Implicit Lock: - Lock is implied but is not acquired
© 2022 - 2024 — McMap. All rights reserved.