当前位置:网站首页>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 ;
边栏推荐
- OLED12864 液晶屏
- Zzuli:1061 sequential output of digits
- “簡單”的無限魔方
- 【论文翻译】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
- [Chongqing Guangdong education] selected reading reference materials of British and American literature of Nanyang Normal University
- LCD之MIPI协议的一些说明
- 软件测试 - 概念篇
- 2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
- Appnuim environment configuration and basic knowledge
- Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
猜你喜欢

我所理解的DRM显示框架

Résumé de la collection de plug - ins couramment utilisée dans les outils de développement idea

idea开发工具常用的插件合集汇总

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

PHP 开发与测试 Webservice(SOAP)-Win

ThreadLocal memory leak

Matplotlib double Y axis + adjust legend position

5g market trend in 2020

centos8安裝mysql8.0.22教程

GRBL 软件:简单解释的基础知识
随机推荐
软件测试 - 概念篇
Practice C language advanced address book design
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Small and medium-sized projects to achieve certification and authorization of hand filter
Determine whether there is an element in the string type
js判断移动端还是pc端
Software testing learning - day 4
PHP read file (read JSON file, convert to array)
The Hong Kong Stock Exchange learned from US stocks and pushed spac: the follow-up of many PE companies could not hide the embarrassment of the world's worst stock market
VSCode paste image插件保存图片路径设置
Typora installation (no need to enter serial number)
Reflection of the soul of the frame (important knowledge)
Brew install * failed, solution
Uva548 tree
Online music player app
460. LFU 缓存 双向链表
Record sentry's path of stepping on the pit
ThreadLocal memory leak
Several keywords in C language
Pytorch Chinese document