当前位置:网站首页>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 (XI) airline ticket crawling company information
- Special topic of data intensive application system design
- How can continuous integration (CI) / continuous delivery (CD) revolutionize automated testing
- Jetpack -- lifecycle usage and source code analysis
- 解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
- Gets all dates between two times
- Pixel mobile phone brick rescue tutorial
- Innovation training (V) configuration information
- The vscode ipynb file does not have code highlighting and code completion solutions
- What's the difference between error and exception
猜你喜欢
[WinUI3]編寫一個仿Explorer文件管理器
Simply drag objects to the item bar
[WinUI3]编写一个仿Explorer文件管理器
深度学习笔记 —— 数据增广
Opencv + clion face recognition + face model training
[database] MySQL multi table query (I)
[database] MySQL single table query
POI export message list (including pictures)
Deep learning notes - semantic segmentation and data sets
使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
随机推荐
PHP 统计指定文件夹下文件的数量
Detailed explanation of hregionserver
Mac 进入mysql终端命令
The vscode ipynb file does not have code highlighting and code completion solutions
独立站运营 | FaceBook营销神器——聊天机器人ManyChat
Jetpack -- lifecycle usage and source code analysis
Innovation training (10)
Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
js 判斷數字字符串中是否含有字符
Innovation training (IV) preliminary preparation - server
Leetcode -- heuristic search
Innovation training (XII) reptile
View analysis of scenic spots in ArcGIS
Innovation training (VII) FBV view & CBV view
List remove an element
Excel protects worksheets and workbooks from damage
[WinUI3]編寫一個仿Explorer文件管理器
Use AES encryption - reuse the wisdom of predecessors
Innovation training (VI) routing
信息学奥赛一本通 1955:【11NOIP普及组】瑞士轮 | OpenJudge 4.1 4363:瑞士轮 | 洛谷 P1309 [NOIP2011 普及组] 瑞士轮