当前位置:网站首页>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 ;
边栏推荐
猜你喜欢

RGB 无限立方体(高级版)

Visual studio import

Stick to the big screen UI, finereport development diary

Appnuim environment configuration and basic knowledge

2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions

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

Importation de studio visuel

Go language web development is very simple: use templates to separate views from logic

Record sentry's path of stepping on the pit

Brew install * failed, solution
随机推荐
php内类名称与类内方法名相同
Record sentry's path of stepping on the pit
Zzuli:1062 greatest common divisor
Zzuli:1066 character classification statistics
all3dp.com网站中全部Arduino项目(2022.7.1)
h5跳小程序
Addchild() and addattribute() functions in PHP
Zzuli:1068 binary number
Visual studio import
Yyds dry inventory what is test driven development
3D printer G code command: complete list and tutorial
DRM display framework as I understand it
[leetcode] day92 container with the most water
GRBL 软件:简单解释的基础知识
PHP read file (read the specified line containing a string in the file)
Balsamiq wireframes free installation
php数组转化为xml
Uva548 tree
PHP parent
3D 打印机 G 代码命令:完整列表和教程