当前位置:网站首页>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
边栏推荐
- Custom switch control
- TypeError: ‘Collection‘ object is not callable. If you meant to call the ......
- JS generates a specified number of characters according to some words
- What is a blocking queue? What is the implementation principle of blocking queue? How to use blocking queue to implement producer consumer model?
- Perfect test of coil in wireless charging system with LCR meter
- QPushButton slot function is triggered multiple times
- 用LCR表完美测试无线充电系统中的线圈
- List< Map> Replication: light copy and deep copy
- QPushbutton 槽函数被多次触发
- 机器学习---线性回归
猜你喜欢
![[database] MySQL multi table query (I)](/img/c7/43167aa6169c24a8d9734032775335.png)
[database] MySQL multi table query (I)

Innovation training (V) configuration information

多线程基本概念(并发与并行、线程与进程)和入门案例

Teach you how to build the ruoyi system by Tencent cloud

用LCR表完美测试无线充电系统中的线圈

What are the redis data types

Unity rawimage background seamlessly connected mobile

COM in wine (2) -- basic code analysis
![[WinUI3]编写一个仿Explorer文件管理器](/img/3e/62794f1939da7f36f7a4e9dbf0aa7a.png)
[WinUI3]编写一个仿Explorer文件管理器
![解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].](/img/99/095063b72390adea6250f7b760d78c.png)
解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
随机推荐
Getprop property
What are the redis data types
HRegionServer的详解
Innovation training (V) configuration information
JS determines whether the numeric string contains characters
js 判斷數字字符串中是否含有字符
C. Tree infection (simulation + greed)
【数据库】MySQL多表查询(一)
Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
Harmonious dormitory (linear DP / interval DP)
The difference between static pipeline and dynamic pipeline
redis数据类型有哪些
负载均衡简介
Spell it! Two A-level universities and six B-level universities have abolished master's degree programs in software engineering!
深度学习笔记 —— 物体检测和数据集 + 锚框
List< Map> Replication: light copy and deep copy
Sword finger offer: the path with a certain value in the binary tree (backtracking)
PHP 统计指定文件夹下文件的数量
How to exit VIM
Set Chrome browser background to eye protection (eye escort / darkreader plug-in)