惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
Cyberwarzone
Cyberwarzone
C
Cybersecurity and Infrastructure Security Agency CISA
Latest news
Latest news
Google Online Security Blog
Google Online Security Blog
Google DeepMind News
Google DeepMind News
K
Kaspersky official blog
Forbes - Security
Forbes - Security
T
Tenable Blog
The Last Watchdog
The Last Watchdog
T
Tor Project blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Simon Willison's Weblog
Simon Willison's Weblog
Project Zero
Project Zero
O
OpenAI News
L
LINUX DO - 热门话题
P
Privacy International News Feed
月光博客
月光博客
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
量子位
博客园 - 【当耐特】
罗磊的独立博客
T
Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Cisco Blogs
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
N
News | PayPal Newsroom
腾讯CDC
Security Latest
Security Latest
J
Java Code Geeks
L
LINUX DO - 最新话题
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Exploit Database - CXSecurity.com
L
Lohrmann on Cybersecurity
D
Docker
Spread Privacy
Spread Privacy
S
Security @ Cisco Blogs
A
Arctic Wolf
H
Hacker News: Front Page
Help Net Security
Help Net Security
Recorded Future
Recorded Future
V2EX - 技术
V2EX - 技术

博客园 - Love Fendi

性能优化系列---查询高cup的sql State模式学习 8.17--8.24积累 sql server 2005 analysis service step by step(三):创建父子维度 sql server 2005 analysis service step by step(二):创建时间维度 sql serve 2005 analysis service step by step(一):创建标准维度 算法练习五:求数组中第k大的数 算法练习四:求N!不溢出 算法练习三:奇偶分割 算法练习二:二分查找 算法练习一:最大公约数与最小公倍数 索引优化 生成验证码,同时异步获取加密后的验证码 自定义控件中与脚本资源集成的若干处理方式 一条语句删除表中某字段重复的数据 动态按需异步加载js文件 在Nhibernate中使用Json.net中出现Self referencing loop的错误的处理 JQuery学习笔记 c#委托事件 入门
数据库锁
Love Fendi · 2009-04-02 · via 博客园 - Love Fendi

锁有两种分类方法。
(1) 从数据库系统的角度来看
锁分为以下三种类型:

  • 独占锁(Exclusive Lock)
    独占锁锁定的资源只允许进行锁定操作的程序使用,其它任何对它的操作均不会被接受。执行数据更新命令,即INSERT、 UPDATE 或DELETE 命令时,SQL Server 会自动使用独占锁。但当对象上有其它锁存在时,无法对其加独占锁。独占锁一直到事务结束才能被释放。
  • 共享锁(Shared Lock)
    共享锁锁定的资源可以被其它用户读取,但其它用户不能修改它。在SELECT 命令执行时,SQL Server 通常会对对象进行共享锁锁定。通常加共享锁的数据页被读取完毕后,共享锁就会立即被释放。
  • 更新锁(Update Lock)
    更新锁是为了防止死锁而设立的。当SQL Server 准备更新数据时,它首先对数据对象作更新锁锁定,这样数据将不能被修改,但可以读取。等到SQL Server 确定要进行更新数据操作时,它会自动将更新锁换为独占锁。但当对象上有其它锁存在时,无法对其作更新锁锁定。

(2)从程序员的角度看
锁分为以下两种类型:

  • 乐观锁(Optimistic Lock)
    乐观锁假定在处理数据时,不需要在应用程序的代码中做任何事情就可以直接在记录上加锁、即完全依靠数据库来管理锁的工作。一般情况下,当执行事务处理时SQL Server会自动对事务处理范围内更新到的表做锁定。
  • 悲观锁(Pessimistic Lock)
    悲观锁对数据库系统的自动管理不感冒,需要程序员直接管理数据或对象上的加锁处理,并负责获取、共享和放弃正在使用的数据上的任何锁。