当前位置:网站首页>事务的基本特性和隔离级别
事务的基本特性和隔离级别
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 串⾏,⼀般是不会使⽤的,他会给每⼀⾏读取的数据加锁,会导致大量超时和锁竞争的问题。
边栏推荐
猜你喜欢

SAP SEGW 事物码里的 ABAP 类型和 EDM 类型映射的一个具体例子

Kotlin variable

Distance measuring sensor chip 4530a used in home intelligent lighting

Discussion on error messages and API versions of SAP ui5 getsaplogonlanguage is not a function

Shi Zhenzhen's 2021 summary and 2022 outlook | colorful eggs at the end of the article

初识Linkerd项目

I met Tencent in the morning and took out 38K, which showed me the basic smallpox

Vonedao solves the problem of organizational development effectiveness

About LDA model

10 minute fitness method reading notes (5/5)
随机推荐
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
在家庭智能照明中应用的测距传感芯片4530A
Super efficient! The secret of swagger Yapi
国内市场上的BI软件,到底有啥区别
Compile kernel modules separately
Insmod prompt invalid module format
RHCSA2
自然语言处理系列(一)入门概述
Concurrent performance test of SAP Spartacus with JMeter
Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
HiEngine:可媲美本地的云原生内存数据库引擎
Yyds dry inventory JS intercept file suffix
I met Tencent in the morning and took out 38K, which showed me the basic smallpox
How can non-technical departments participate in Devops?
Get to know linkerd project for the first time
Setting up sqli lab environment
NLP engineer learning summary and index
Didi open source Delta: AI developers can easily train natural language models
I'm doing open source in Didi
Free testing of Taobao tmall API order and flag insertion remark interface