当前位置:网站首页>【学习笔记】数据库中锁的分类
【学习笔记】数据库中锁的分类
2022-07-27 15:58:00 【棉花糖灬】
从锁的共享性/数据库管理角度划分,可以将锁分为共享锁和排它锁。
共享锁(S锁):又称读锁,用于不修改数据的只读操作,如select语句。当一个事务对数据加共享锁后,其他事务只能对相同的事务再加共享锁,而不能加排它锁。获取共享锁的事务只能读取数据,而不能修改数据。
排它锁(X锁):又称写锁,用于修改数据的操作,如insert、update、delete语句。当一个事务对数据加排它锁后,其他事务不能再对该数据加任何锁。获取排它锁的事务既能读取数据,又能修改数据。
从加锁方式/程序员角度划分,可以将锁分为乐观锁和悲观锁。
乐观锁:加锁时采取乐观的态度,即不会出现冲突,先操作,若无冲突则直接成功,若冲突再处理。
悲观锁:加锁时采取悲观的态度,即一定会出现冲突,无论有冲突,都先加锁,再操作。
从枷锁的粒度划分,可以将锁分为行锁和表锁等。
行锁:把数据库表的一行锁定,开销大,锁粒度小,发生冲突几率小,并发性高。
表锁:把数据库的整张表锁定,开销小,锁粒度大,发生冲突几率大,并发性低。
边栏推荐
- WPF makes login interface
- JDBC connection database reading foreground cannot display data
- Resolve merge fields in salesforce
- JSP custom tag (bottom)
- Convolutional neural network -- from r-cnn, fast r-cnn to fast r-cnn, mask r-cnn
- Convolutional neural network -- Translation of yolov2 (yolo9000) papers
- 细数国产接口协作平台的六把武器!
- Soul 1: why is es more suitable for complex condition search than MySQL?
- Anaconda uninstall again
- Knowledge dry goods: basic storage service novice Experience Camp
猜你喜欢

WebDriverException( selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executabl

Fast analysis combined with Haidian medicine

机器学习之评价指标(二)——分类评价指标

卷积神经网络——YOLOV2(YOLO9000)论文翻译

Convolutional neural network -- from r-cnn, fast r-cnn to fast r-cnn, mask r-cnn

JSP custom tag (bottom)

XStream reports an error abstractreflectionconverter$unknownfield exception when parsing XML

Are those who are absent from the written examination shortlisted for the teacher recruitment interview? Henan Xiangfu: the statistics of individual candidates' scores are wrong

Operation of simulated examination platform for 2022 low voltage electrician examination questions

知物由学 | 关联图分析在反作弊业务中的应用
随机推荐
ES查询限制10000条数据解决方法
How difficult the interview is! I was forced to survive the six rounds of interview of ant financial! Almost out (interview resumption)
施耐德电气、欧莱雅等企业巨头如何开放式创新?DEMO WORLD世界创新峰会揭秘
I got the P8 "top-level" distributed architecture manual crazy spread on Alibaba intranet
How to learn C language? This article gives you the complete answer
Es query limit 10000 data solutions
You can't specify target table 'table name' for update in from clause error resolution in MySQL
fragmentTransaction.replace第二个参数报错
Convolutional neural network -- Translation of yolov1 thesis
【cf】#681 A. Kids Seating (Div. 2, based on VK Cup 2019-2020 - Final)
[Southwest University] information sharing of postgraduate entrance examination and re examination
卷积神经网络——从R-CNN,Fast R-CNN到Faster R-CNN,Mask R-CNN
WPF makes login interface
Convolutional neural network -- from r-cnn, fast r-cnn to fast r-cnn, mask r-cnn
登录页面tableLayout(表格布局)
How to resolve the public domain name to the intranet IP server -- quickly resolve the domain name and map the Internet access
With the right tools, CI achieves twice the result with half the effort
微信小程序 实现位置地图显示,引入map地图,不含导航
Convolutional neural network -- Translation of yolov2 (yolo9000) papers
微信小程序 实现拨打电话