数据库中显式锁和隐式锁有什么区别?

发布于 2024-09-18 10:57:58 字数 24 浏览 5 评论 0原文

数据库中显式锁和隐式锁有什么区别?

What is the difference between an explicit and an implicit lock in database?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

若言繁花未落 2024-09-25 10:57:58

隐式锁通常由 DBMS 自动放置。大多数 DBMS 允许开发人员或应用程序发出锁,称为显式锁。

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.

绅士风度i 2024-09-25 10:57:58

隐式锁定

Objectivity/DB 将在需要时为您的应用程序隐式获取适当的锁定。读取对象的操作将获得读锁;修改对象的操作将获得写锁。

显式锁定

隐式锁定获取应用程序需要的资源的访问权限。一般来说,Objectivity/DB 的自动锁定提供了足以满足大多数应用程序的联合数据库并发级别。

然而,某些应用程序可能需要提前保留对所有所需资源的访问权限。这样做的原因可能是为了在开始操作之前确保对必要对象的所需访问权限,或者防止其他会话修改对操作至关重要的对象。

需要提前保留对所有必需对象的访问的应用程序可以显式锁定对象。假设应用程序需要根据特定时间点的许多对象的状态来计算值。尽管应用程序无法同时检查所有必需的对象,但通过冻结对象的状态然后按顺序检查它们可以达到相同的效果。显式锁定有效地冻结了对象,因为只要它们被锁定,其他会话就无法修改它们。

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.

岛歌少女 2024-09-25 10:57:58
  • 显式锁定: - 对记录或表显式请求锁定。
  • 隐式锁:- 隐含锁但不获取锁
  • Explicit Lock: - Lock is explicitly requested for a record or table.
  • Implicit Lock: - Lock is implied but is not acquired
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文