查看: 12628|回复: 21

什么是悲观锁定和乐观锁定?

[复制链接]
论坛徽章:
3
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33
跳转到指定楼层
1#
发表于 2005-4-1 08:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
什么是悲观锁定和乐观锁定?
论坛徽章:
112
2008新春纪念徽章
日期:2008-02-13 12:43:03马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上加薪
日期:2014-02-19 11:55:14马上有车
日期:2014-11-03 12:40:39沸羊羊
日期:2015-03-04 14:43:432015年新春福章
日期:2015-03-06 11:57:31慢羊羊
日期:2015-03-09 16:15:39
2#
发表于 2005-4-1 09:06 | 只看该作者
乐观锁:完全依靠数据库来管理锁的工作。
悲观锁:应用程序自己管理数据或对象上的锁处理

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
122
马上加薪
日期:2014-02-19 11:55:14ITPUB官方微博粉丝徽章
日期:2011-06-28 19:45:36管理团队成员
日期:2011-05-07 01:45:082010广州亚运会纪念徽章:拳击
日期:2011-03-29 13:11:152010广州亚运会纪念徽章:篮球
日期:2011-02-20 22:50:172011新春纪念徽章
日期:2011-02-18 11:42:492011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
3#
发表于 2005-4-1 15:29 | 只看该作者
up

使用道具 举报

回复
论坛徽章:
5
ITPUB元老
日期:2005-03-15 09:15:43ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44凯迪拉克
日期:2013-12-27 09:30:49
4#
发表于 2005-4-1 17:58 | 只看该作者
哪里的概念?
从来没听过的?

使用道具 举报

回复
论坛徽章:
3
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33
5#
 楼主| 发表于 2005-4-2 09:14 | 只看该作者
我对Toms_zhang的回答不是很满意,还有没有其它的答案?

使用道具 举报

回复
论坛徽章:
7
ITPUB元老
日期:2005-09-18 11:00:10授权会员
日期:2005-10-30 17:05:33数据库板块每日发贴之星
日期:2005-12-21 01:01:31会员2006贡献徽章
日期:2006-04-17 13:46:34会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44蛋疼蛋
日期:2012-02-13 13:03:57
6#
发表于 2005-4-4 11:32 | 只看该作者
Oracle Internals page 57

Consider an airline seat reservation application. Two different customers may
simultaneously ask two different operators whether a seat is available on a
particular flight. What should the application do?
The application can use SELECT FOR UPDATE NOWAIT to retrieve the
information. This guarantees that if a seat appears to be available, then it has
already been locked, and a booking for that seat will be able to be successfully
taken. This is called early locking, or pessimistic locking.
The alternative is to defer the taking of a lock until the customer resolves to make
a booking. This is called late locking, or optimistic locking.
The choice of either pessimistic or optimistic locking affects the design of both
business and application processes. So careful thought is needed. Pessimistic
locking should be avoided where possible, despite being slightly easier to
implement, because it increases the risk of blocking locks.

使用道具 举报

回复
论坛徽章:
3
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33
7#
 楼主| 发表于 2005-4-4 20:06 | 只看该作者
很满意teddyboy的回答! 谢谢

使用道具 举报

回复
论坛徽章:
3
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33
8#
 楼主| 发表于 2005-4-4 20:06 | 只看该作者
很满意teddyboy的回答! 谢谢 那如果不用for update的语, 一般情况下都是乐观锁定吧!

使用道具 举报

回复
论坛徽章:
0
9#
发表于 2009-6-27 15:20 | 只看该作者
up

使用道具 举报

回复
论坛徽章:
31
数据库板块每日发贴之星
日期:2008-08-25 01:02:02数据库板块每日发贴之星
日期:2011-08-14 01:01:01茶鸡蛋
日期:2011-08-14 16:42:13ITPUB十周年纪念徽章
日期:2011-09-27 16:32:49ITPUB十周年纪念徽章
日期:2011-11-01 16:24:512012新春纪念徽章
日期:2012-01-04 11:54:26版主1段
日期:2012-05-15 15:24:11ITPUB 11周年纪念徽章
日期:2012-10-09 18:09:19现任管理团队成员
日期:2012-10-18 17:10:24马上有车
日期:2014-02-19 11:55:14
10#
发表于 2009-6-28 13:29 | 只看该作者
推荐读Tom大师的Oracle 9i&10g编程艺术

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表