当前位置:网站首页>【学习笔记】数据库中锁的分类
【学习笔记】数据库中锁的分类
2022-07-27 15:58:00 【棉花糖灬】
从锁的共享性/数据库管理角度划分,可以将锁分为共享锁和排它锁。
共享锁(S锁):又称读锁,用于不修改数据的只读操作,如select语句。当一个事务对数据加共享锁后,其他事务只能对相同的事务再加共享锁,而不能加排它锁。获取共享锁的事务只能读取数据,而不能修改数据。
排它锁(X锁):又称写锁,用于修改数据的操作,如insert、update、delete语句。当一个事务对数据加排它锁后,其他事务不能再对该数据加任何锁。获取排它锁的事务既能读取数据,又能修改数据。
从加锁方式/程序员角度划分,可以将锁分为乐观锁和悲观锁。
乐观锁:加锁时采取乐观的态度,即不会出现冲突,先操作,若无冲突则直接成功,若冲突再处理。
悲观锁:加锁时采取悲观的态度,即一定会出现冲突,无论有冲突,都先加锁,再操作。
从枷锁的粒度划分,可以将锁分为行锁和表锁等。
行锁:把数据库表的一行锁定,开销大,锁粒度小,发生冲突几率小,并发性高。
表锁:把数据库的整张表锁定,开销小,锁粒度大,发生冲突几率大,并发性低。
边栏推荐
- Multi thread implementation loop
- VSS tip: search all checked out files (search checked out files according to users)
- JS to realize the right-click menu bar function
- How to learn C language? This article gives you the complete answer
- Machine learning: IOU of concept understanding
- MySql代码数据库创建 停车管理系统 外键
- IDEA打包war包与war包位置
- How to solve the error of ora-00955 when Oracle modifies the primary key
- Hutool array tool
- golang 等待一组goroutine完成,并带返回值(2)
猜你喜欢

机器学习之评价指标(一)——回归评价指标

Wechat applet to make calls

canvas根据坐标点绘制图形

2022 safety officer-a certificate examination questions and online simulation examination

Know things by learning | build a real-time anti plug-in mechanism from 0 to 1 to supplement the offensive and defensive power of mobile games in multiple dimensions

Six relationships of classes -- the difference between dependency and Association
知物由学 | SO加固如何提升Android应用的安全性?

面试好难啊!蚂蚁金服的六轮面试我是强撑过来!差点OUT(面试复盘)

机器学习——概念理解之IoU

Salesforce certified sharing and visibility Designer (su20) certification examination summary
随机推荐
Fast parsing combined with Huatu document encryption software
With the right tools, CI achieves twice the result with half the effort
机器学习之评价指标(一)——回归评价指标
知物由学 | 关联图分析在反作弊业务中的应用
fragmentTransaction.replace第二个参数报错
Understand │ what is cross domain? How to solve cross domain problems?
知物由学 | SO加固如何提升Android应用的安全性?
Machine learning: IOU of concept understanding
Yanrong technology was selected as Beijing's "specialized and innovative" in 2022 to lead hybrid cloud file storage
Summer Challenge [FFH] real time chat room websocket practice
Convolutional neural network -- Introduction to FPN (feature pyramid networks)
Configuration and basic use of vim
Does PostgreSQL 14 support winserver2022?
What's the use of games| Game application value research case collection
面试好难啊!蚂蚁金服的六轮面试我是强撑过来!差点OUT(面试复盘)
Could not obtain transaction-synchronized Session for current thread
hutool- 数组工具
WPF makes login interface
IDEA打包war包与war包位置
【Codeforces】 B. Make it Divisible by 25