当前位置:网站首页>MySQL transaction
MySQL transaction
2022-07-22 08:28:00 【Dried bamboo shoots zzz~】
MySQL Business :
One 、 Transaction execution process :
Two 、 The basic elements of a business (ACID)
1、 Atomicity (Atomicity): All operations after the transaction begins , Or all of them , Or not at all , It's impossible to stay in the middle . An error occurred during the execution of the transaction , It rolls back to the state it was in before the transaction started , All the operations are as if they didn't happen . That is to say, a business is an indivisible whole , It's like atoms in chemistry , Is the basic unit of material composition , Is the smallest particle of chemical change .
2、 Uniformity (Consistency): Before and after the transaction starts , The database integrity constraint is not broken . This means that the data written must fully comply with all the default rules , such as A towards B Transfer accounts , impossible A Buckle the money ,B Has received .
3、 Isolation, (Isolation): At the same time , Only one transaction is allowed to request the same data , There is no interference between the different transactions . such as A Withdrawing money from a bank card , stay A Before the withdrawal process is over ,B You can't transfer money to this card .
4、 persistence (Durability): After the transaction completes , All updates to the database by the transaction are saved to the database , Cannot be rolled back .
3、 ... and 、 Concurrency of transactions
1、 Dirty reading : Dirty read refers to reading uncommitted data from other transactions , Uncommitted means that the data may be rolled back , That is, it may not be stored in the database eventually , That is, data that doesn't exist . Read the data that must eventually exist , This is dirty reading .
2、 It can't be read repeatedly : Contrast can be read repeatedly , Nonrepeatable reading refers to within the same transaction , The same batch of data read at different times may be different , May be affected by other things , For example, other transactions change this batch of data and commit . Usually for data updates (UPDATE) operation .
3、 Repeatable : Repeatable reading refers to within a transaction , The first read data is consistent with the same batch of data read at any time before the end of the transaction . Usually for data updates (UPDATE) operation .
4、 Fantasy reading : Unreal reading is for data insertion (INSERT) In terms of operation . What if A View the contents of some lines , But it hasn't been submitted yet , At this point, the transaction B Insert transaction A What to view , And in business A Submitted before submitting , And then , In the transaction A If you query again in, you will find that it is different , But it's business B Just inserted in , It makes users feel magical , I feel like I'm hallucinating , This is called Unreal reading .
Four 、 Transaction isolation level
SQL The standard defines four levels of isolation ,MySQL All support . The four isolation levels are :
- Read uncommitted (READ UNCOMMITTED)
- Read the submission (READ COMMITTED)
- Repeatable (REPEATABLE READ)
- Serialization (SERIALIZABLE)
From the top down , The intensity of isolation gradually increases , Performance is getting worse . Which isolation level to adopt depends on the trade-off between system requirements , among , Repeatable reading is MySQL Default level for .
Transaction isolation is actually to solve the above-mentioned dirty reading 、 It can't be read repeatedly 、 Some questions about illusory reading , The following shows 4 The degree to which these three problems are solved by the isolation level .
边栏推荐
- STM32 Hal library SPI always reads FF. Solve the problem!
- Matrix multiplication and division of two elements "suggestions collection"
- pytorch如何将Variable或Tensor转换为numpy?
- 8位补码booth一位乘法器
- Spark 读取csv文件操作,option参数解释
- No.js--- based on V8 and IO_ Running JS runtime
- 线程池7个参数的含义
- 数据分析与挖掘1
- mysql的binlog
- R language uses LM function to build multiple linear regression model and build regression model without intercept term (the model does not contain intercept)
猜你喜欢
Error: L6218E: Undefined symbol SX1276FskGetPacketCrcOn (referred from sx1276-fsk.o)
How excel automatically matches gender code according to ID number
Integrate efk with odoo to realize log visualization
自学golang【3.3go语言的循环语句】for循环语法结构,省略初始条件,省略递增条件,省略结束条件的应用
Fast Fourier transform, Lagrange interpolation, three thousand words with examples, sister chapters, application of FFT and string matching
Sum the numbers in the region using the sum function
Error: L6218E: Undefined symbol SX1276FskGetPacketCrcOn (referred from sx1276-fsk.o)
Verilog——74HC194多功能双向移位寄存器
Airflow详细搭建过程(亲测 + 总结)
MySql中on与where的区别个人总结——分清楚条件应该写在哪里
随机推荐
Why not overwrite when pasting in excel
R language ggplot2 visualization: use the ggarrange function of ggpubr package to combine multiple images, and use the nrow parameter to specify the number of rows in the combined image
Fast Fourier transform, Lagrange interpolation, three thousand words with examples, sister chapters, application of FFT and string matching
Intégration de l'efk avec l'odoo pour réaliser la visualisation des journaux
How to cache with blob object in browser
深度学习之Tensorflow框架实现VGG/RNN网络/验证码生成与识别/文本分类
Installing MySQL on Linux (CentOS)
Can you do application development without programming? Yes!
excel 如何根据身份证号自动匹配性别代码
STM32 SPI reading data is inaccurate, only the first time is correct, and the latter is not correct
Error: L6200E: Symbol keyflag multiply defined (by main.o and key.o).
SPI debugging is not successful, it is likely that you connected the wrong cable!!
How to open stdio in C h ? How to find the definition of printf?
C中如何打开stdio.h ? 如何找到printf的定义?
Shell练习:统计词频
How does idea import automatically
云安全日报220721:思科混合云运维管理解决方案发现执行任意命令漏洞,需要尽快升级
Make sure your hardware is connected stably before coding!!!
Detailed explanation of wireless charging principle and Qi protocol [easy to understand]
NotePad++中如何把横向闪烁光标( _ )修改成竖向闪烁光标样式( | )?