当前位置:网站首页>事务的基本特性和隔离级别
事务的基本特性和隔离级别
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 串⾏,⼀般是不会使⽤的,他会给每⼀⾏读取的数据加锁,会导致大量超时和锁竞争的问题。
边栏推荐
- Reshape the power of multi cloud products with VMware innovation
- 2021-12-21 transaction record
- Distance measuring sensor chip 4530a used in home intelligent lighting
- 非技术部门,如何参与 DevOps?
- 国内市场上的BI软件,到底有啥区别
- It's too convenient. You can complete the code release and approval by nailing it!
- Yyds dry inventory JS intercept file suffix
- 2021-12-22 transaction record
- ##无监控,不运维,以下是监控里常用的脚本监控
- 我在滴滴做开源
猜你喜欢
你的下一台电脑何必是电脑,探索不一样的远程操作
RHCAS6
Notes for preparation of information system project manager --- information knowledge
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
946. 验证栈序列
SAP SEGW 事物码里的导航属性(Navigation Property) 和 EntitySet 使用方法
我在滴滴做开源
SAP self-development records user login logs and other information
SAP UI5 FlexibleColumnLayout 控件介绍
SAP SEGW 事物码里的 ABAP Editor
随机推荐
深度长文探讨Join运算的简化和提速
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
2021-12-21 transaction record
HiEngine:可媲美本地的云原生内存数据库引擎
SAP SEGW 事物码里的 ABAP Editor
What is the difference between Bi software in the domestic market
逆波兰表达式
946. Verify stack sequence
SAP 自开发记录用户登录日志等信息
10 minute fitness method reading notes (5/5)
NFT: how to make money with unique assets?
Compile kernel modules separately
使用 jMeter 对 SAP Spartacus 进行并发性能测试
Free testing of Taobao tmall API order and flag insertion remark interface
Taobao flag insertion remarks | logistics delivery interface
Kotlin function
Developers, is cloud native database the future?
How do e-commerce sellers refund in batches?
VoneDAO破解组织发展效能难题
Neural network of PRML reading notes (1)