当前位置:网站首页>MySQL transaction and isolation level
MySQL transaction and isolation level
2022-07-02 05:51:00 【Zebra!】
Catalog
1. The concept and special effects of transactions
1.2 The transaction acid attribute
1.3 Concurrency problems caused by multiple transactions
3. The isolation level of the transaction
1. The concept and special effects of transactions
1.1 Business
Transactions consist of one or more of a single unit SQL Sentence composition , In this unit , Every SQL Sentences are interdependent . And the whole single unit as an integral whole , If one of the units SQL Once the statement fails or generates an error , The entire unit will roll back . All affected data will be returned to the state before the transaction ; If all of the units SQL Statements are executed successfully , Then the transaction is executed smoothly .
1.2 The transaction acid attribute
Atomicity : Atomicity means that a transaction is an indivisible unit of work , Either the operations in the transaction occur , Or none at all .
Uniformity : Transactions must transform the database from one consistency state to another .
Isolation, : Transaction isolation means that the execution of one transaction cannot be interfered by other transactions , That is, the operations within a transaction and the data it uses are isolated from other concurrent transactions , Transactions that execute concurrently cannot interfere with each other .
persistence : Persistence means that once a transaction is committed , Its changes to the data in the database are permanent , Other subsequent operations and database failures should not have any impact on it .
1.3 Concurrency problems caused by multiple transactions
For multiple transactions running simultaneously , When these transactions access the same data in the database , If necessary isolation mechanism is not adopted , It can lead to various concurrency problems ;
Dirty reading : For two things T1, T2, T1 Read has been T2 Fields updated but not yet submitted . after , if T2 Roll back , T1 The read content is temporary and invalid .
It can't be read repeatedly : For two things t1,t2, If t1 Read a field , whatever t2 Updated the field , after ,t1 Read the same field again , The value is different .
Fantasy reading : For two things t1,t2, If t1 Read a field from a table , then t2 Some new rows are inserted into the table , after , If t1 Read the same table again , There will be a few more lines .
2. Transaction processing
- Business (transaction) A group of SQL sentence
- return (rollback) Revocation of execution SQL Statement procedure
- Submit (commit) Will be executed for SQL Statement to write to the database table
- Reservation point (savepoint) Temporary storage point , Used to publish returns
3. The isolation level of the transaction
1) Isolation of database transactions : The database system must have the ability to isolate and run transactions concurrently , So that they will not affect each other , Avoid all kinds of concurrent problems ;
2) The degree to which a transaction is isolated from other transactions is called the isolation level . The database specifies multiple transaction isolation levels , Different isolation levels correspond to different interference levels , Higher isolation level , The better the data consistency , But the weaker the distribution .
3)4 Kind of isolation level
4) Set isolation level
- set transaction isolation level read committed : Set up current mysql Isolation level of the connection ;
- set global transaction isolation level read committed: Set the global isolation level of the database system ;
边栏推荐
- Stick to the big screen UI, finereport development diary
- Record sentry's path of stepping on the pit
- Reflection of the soul of the frame (important knowledge)
- Technologists talk about open source: This is not just using love to generate electricity
- Installation du tutoriel MySQL 8.0.22 par centos8
- With an amount of $50billion, amd completed the acquisition of Xilinx
- 软件测试 - 概念篇
- Zzuli:1060 numbers in reverse order
- ThreadLocal memory leak
- PHP read file (read the specified line containing a string in the file)
猜你喜欢
深度学习分类网络--Network in Network
all3dp. All Arduino projects in com website (2022.7.1)
Alibaba: open source and self-developed liquid cooling data center technology
File contains vulnerabilities (II)
Lantern Festival gift - plant vs zombie game (realized by Matlab)
brew install * 失败,解决方法
OLED12864 液晶屏
GRBL 软件:简单解释的基础知识
Thunder on the ground! Another domestic 5g chip comes out: surpass Huawei and lead the world in performance?
Can't the dist packaged by vite be opened directly in the browser
随机推荐
XSS basic content learning (continuous update)
Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
Oled12864 LCD screen
File contains vulnerability (I)
"Simple" infinite magic cube
软件测试基础篇
Several keywords in C language
js判断移动端还是pc端
Gcnet: non - local Networks meet Squeeze excitation Networks and Beyond
数据库学习总结5
Software testing - concept
记录sentry的踩坑之路
Visual Studio導入
Yyds dry inventory what is test driven development
Practice C language advanced address book design
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
PHP read file (read JSON file, convert to array)
PHP development and testing WebService (soap) -win
Zzuli:1065 count the number of numeric characters
460. LFU 缓存 双向链表