当前位置:网站首页>Acid of MySQL transaction
Acid of MySQL transaction
2022-04-23 04:59:00 【GreatorMan】
MYSQL In the execution of complex 、 multiple SQL when , The execution process is either fully successful , Or it's a total failure . For example, when executing multiple SQL, A few days ago SQL Successful implementation , One of the SQL collapse , And back out the data of the impact of successful execution . Let's take a bank transfer as an example :
scene :
Zhang San goes to the bank counter to transfer money to Wang Wu 500 element .
software design :
There is an account form (acc), Storage is : Account No (acc_no)、 Available balance (surplus).
Transfer logic :
1、 Judge whether Zhang San's account balance is greater than 500 element
2、 Zhang San's account balance minus 500 element
3、 Add... To Wang Wu's account 500 element
Convert to SQL as follows :
1)SELECT surplus FROM acc WHERE acc_no=' Zhang San's account ';
2)UPDATE FROM acc SET surplus=surplus-500 WHERE acc_no=' Zhang San's account ';
3)UPDATE FROM acc SET surplus=surplus+500 WHERE acc_no=' Wang Wu account ';
In the previous scenario, if there was no transaction mechanism , If we are transferring money, we may be implementing Article 2 SQL Failure , This will not affect the available balance of Wang Wu's account , But in Implementing Article 3 SQL Execution failed , It will lead to less Zhang San 500 Yuan , Wang Wu didn't receive this 500 Yuan . Transactions are very important in manipulating data .
A strict transaction support must follow ACID;
Atomicity (Atomicity)
Atomicity means that a transaction is an indivisible unit of work , Either the operations in the transaction occur , Or none at all .
Uniformity (Consistency)
The total weight of the data in the database changes from one complete and consistent state to another . After the transaction is executed, Zhang San either transfers money successfully , Own account is small 500, Wang Wu has many accounts 500; Keep the available balance of the account unchanged .
Isolation, (Isolation)
Transaction isolation is when multiple users access the database concurrently , A transaction opened by a database for each user , Can't be disturbed by the operation data of other transactions , Multiple concurrent transactions should be isolated from each other . When no more operations can be performed , Others also operate on your data , Non isolation between transactions leads to
persistence (Durability)
Persistence means that once a transaction is committed , It changes the data in the database permanently , Next, even if the database fails, it should not have any impact
版权声明
本文为[GreatorMan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220553102092.html
边栏推荐
- Innovation training (V) mid term inspection
- Unity3d practical skills - theoretical knowledge base (I)
- Learning Android from scratch -- baseactivity and activitycollector
- Differences between redis and MySQL
- 敏捷实践 | 提高小组可预测性的敏捷指标
- AQS source code reading
- Innovation training (IX) integration
- Detailed explanation of the differences between TCP and UDP
- 信息学奥赛一本通 1212:LETTERS | OpenJudge 2.5 156:LETTERS
- Innovation training (II) task division
猜你喜欢
MySQL - index
DIY 一个 Excel 版的子网计算器
Teach you how to build the ruoyi system by Tencent cloud
深度学习笔记 —— 数据增广
Sword finger offer: the path with a certain value in the binary tree (backtracking)
Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
Pixel mobile phone brick rescue tutorial
Learning Android from scratch -- Introduction
Unity rawimage background seamlessly connected mobile
随机推荐
[winui3] write an imitation Explorer file manager
和谐宿舍(线性dp / 区间dp)
Arduino UNO r3+LCD1602+DHT11
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
SCP command details
PHP counts the number of files in the specified folder
Leetcode -- heuristic search
Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
#define 定义常量和宏,指针和结构体
Leetcode 1547: minimum cost of cutting sticks
Innovation training (V) mid term inspection
DIY is an excel version of subnet calculator
Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
Custom switch control
Innovation training (VII) FBV view & CBV view
Detailed explanation of the differences between TCP and UDP
MySQL - index
C# List字段排序含有数字和字符
[database] MySQL multi table query (I)
JS détermine si la chaîne de nombres contient des caractères