当前位置:网站首页>事务的基本特性和隔离级别
事务的基本特性和隔离级别
2022-07-05 12:43:00 【51CTO】
事务的特性
事务的定义很严格,它必须同时满足四个特性,即原子性、一致性、隔离性和持久性,也就是人们俗称的 ACID 特性,具体如下。
1)原子性(Atomic)
表示是⼀个事务中的操作要么全部成功,要么全部失败。
2)一致性(Consistency)
指的是数据库总是从⼀个⼀致性的状态转换到另外⼀个⼀致性的状态。
3)隔离性(Isolation)
指的是⼀个事务的修改在最终提交前,对其他事务是不可⻅的。
4)持久性(Durability)
指的是⼀旦事务提交,所做的修改就会永久保存到数据库中。
事务的隔离级别
| 隔离级别 | 中文名称 |
|---|---|
| read uncommint | 读未提交 |
| read commit | 读已提交 |
| repeatable read | 可重复读 |
| serializable | 串行化 |
- read uncommit 读未提交,可能会读到其他事务未提交的数据,也叫做脏读。
- ⽤户本来应该读取到id=1的⽤户age应该是10,结果读取到了其他事务还没有提交的事务,结果读取结果age=20,这就是脏读。
- read commit 读已提交,两次读取结果不⼀致,叫做不可重复读。 不可重复读解决了脏读的问题,他只会读取已经提交的事务。
- ⽤户开启事务读取id=1⽤户,查询到age=10,(其他事务已提交)再次读取发现结果=20,在同⼀个事务⾥同⼀个查询 读取到不同的结果叫做不可重复读。
- repeatable read 可重复复读,这是mysql的默认级别,就是每次读取结果都⼀样,但是有可能产生幻读。
- serializable 串⾏,⼀般是不会使⽤的,他会给每⼀⾏读取的数据加锁,会导致大量超时和锁竞争的问题。
边栏推荐
- Why is your next computer a computer? Explore different remote operations
- 【Nacos云原生】阅读源码第一步,本地启动Nacos
- 155. Minimum stack
- #yyds干货盘点#js截取文件后缀名
- Reshape the power of multi cloud products with VMware innovation
- About the single step debugging of whether SAP ui5 floating footer is displayed or not and the benefits of using SAP ui5
- Association modeling method in SAP segw transaction code
- 2021-12-21 transaction record
- Taobao, pinduoduo, jd.com, Doudian order & Flag insertion remarks API solution
- Compilation principle reading notes (1/12)
猜你喜欢

石臻臻的2021总结和2022展望 | 文末彩蛋

Introduction to sap ui5 flexiblecolumnlayout control

我在滴滴做开源

Association modeling method in SAP segw transaction code

Introduction to sap ui5 dynamicpage control

How to connect the API interface of Taobao open platform (super detailed)

研究:数据安全工具在 60% 的情况下无法抵御勒索软件

Research: data security tools cannot resist blackmail software in 60% of cases

Introduction aux contrôles de la page dynamique SAP ui5

Discussion on error messages and API versions of SAP ui5 getsaplogonlanguage is not a function
随机推荐
946. 验证栈序列
It's too convenient. You can complete the code release and approval by nailing it!
How can non-technical departments participate in Devops?
Talk about my drawing skills in my writing career
从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
Compilation principle reading notes (1/12)
RHCSA7
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
【云原生】Nacos中的事件发布与订阅--观察者模式
Taobao short video, why the worse the effect
Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
将函数放在模块中
超高效!Swagger-Yapi的秘密
LeetCode20.有效的括号
Research: data security tools cannot resist blackmail software in 60% of cases
自然语言处理从小白到精通(四):用机器学习做中文邮件内容分类
【云原生】Nacos-TaskManager 任务管理的使用
由扫地增而引起的小叙
单独编译内核模块
insmod 提示 Invalid module format