当前位置:网站首页>事务的基本特性和隔离级别
事务的基本特性和隔离级别
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 串⾏,⼀般是不会使⽤的,他会给每⼀⾏读取的数据加锁,会导致大量超时和锁竞争的问题。
边栏推荐
- RHCSA7
- 函数的默认参数&函数参数的多种方法
- [cloud native] use of Nacos taskmanager task management
- SAP ui5 objectpagelayout control usage sharing
- Natural language processing from Xiaobai to proficient (4): using machine learning to classify Chinese email content
- SAP self-development records user login logs and other information
- Transactions from January 14 to 19, 2022
- Transactions from January 6 to October 2022
- SAP UI5 DynamicPage 控件介绍
- Association modeling method in SAP segw transaction code
猜你喜欢

Taobao short videos are automatically released in batches without manual RPA open source

使用 jMeter 对 SAP Spartacus 进行并发性能测试

946. Verify stack sequence

Developers, is cloud native database the future?

CF:A. The Third Three Number Problem【关于我是位运算垃圾这个事情】

OpenHarmony应用开发之Navigation组件详解

Transactions from December 27 to 28, 2021

How to connect the API interface of Taobao open platform (super detailed)
![[cloud native] event publishing and subscription in Nacos -- observer mode](/img/0f/34ab42b7fb0085f58f36eb67b6f107.png)
[cloud native] event publishing and subscription in Nacos -- observer mode

Alipay transfer system background or API interface to avoid pitfalls
随机推荐
Association modeling method in SAP segw transaction code
#yyds干货盘点# 解决名企真题:搬圆桌
Distance measuring sensor chip 4530a used in home intelligent lighting
Kotlin function
155. Minimum stack
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
Taobao, pinduoduo, jd.com, Doudian order & Flag insertion remarks API solution
Rasa Chat Robot Tutorial (translation) (1)
由扫地增而引起的小叙
SAP UI5 ObjectPageLayout 控件使用方法分享
Taobao order amount check error, avoid capital loss API
leetcode:221. 最大正方形【dp状态转移的精髓】
How can non-technical departments participate in Devops?
SAP SEGW 事物码里的 ABAP 类型和 EDM 类型映射的一个具体例子
关于 SAP UI5 getSAPLogonLanguage is not a function 的错误消息以及 API 版本的讨论
Natural language processing series (I) introduction overview
Developers, is cloud native database the future?
A few years ago, I outsourced for four years. Qiu Zhao felt that life was like this
RHCSA3
How do e-commerce sellers refund in batches?