当前位置:网站首页>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 ;
边栏推荐
- 我所理解的DRM显示框架
- [paper translation] gcnet: non local networks meet squeeze exception networks and beyond
- ThreadLocal memory leak
- Usage record of vector
- 简单封装 js并应用
- Practice C language advanced address book design
- Win10 copy files, save files... All need administrator permission, solution
- PHP read file (read the specified line containing a string in the file)
- Installation du tutoriel MySQL 8.0.22 par centos8
- 深度学习分类网络 -- AlexNet
猜你喜欢

Cube magique infini "simple"

Alibaba: open source and self-developed liquid cooling data center technology

RNN recurrent neural network

Win10 copy files, save files... All need administrator permission, solution

15 C language advanced dynamic memory management

深度学习分类网络--VGGNet

Installation du tutoriel MySQL 8.0.22 par centos8

Centos8 installation mysql8.0.22 tutorial

“簡單”的無限魔方

Brew install * failed, solution
随机推荐
LCD之MIPI协议的一些说明
Zzuli:1064 encrypted characters
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
Addchild() and addattribute() functions in PHP
记录sentry的踩坑之路
PHP inner class name is the same as the inner class method name
Applet jumps to official account
[personal test] copy and paste code between VirtualBox virtual machine and local
VSCode paste image插件保存图片路径设置
[Chongqing Guangdong education] selected reading reference materials of British and American literature of Nanyang Normal University
"Simple" infinite magic cube
ThreadLocal memory leak
Record sentry's path of stepping on the pit
Grbl software: basic knowledge of simple explanation
Visual Studio导入
Small and medium-sized projects to achieve certification and authorization of hand filter
Uva548 tree
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
Typora installation (no need to enter serial number)
php按照指定字符,获取字符串中的部分值,并重组剩余字符串为新的数组