当前位置:网站首页>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 ;
边栏推荐
- Typora installation (no need to enter serial number)
- Pytorch Basics
- Online music player app
- 来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
- Test case
- 数据挖掘方向研究生常用网站
- Can't the dist packaged by vite be opened directly in the browser
- PHP read file (read JSON file, convert to array)
- Pytorch Chinese document
- Get the details of the next largest number
猜你喜欢

【技术随记-08】

Matplotlib double Y axis + adjust legend position

mysql事务和隔离级别

文件包含漏洞(二)

Practice C language advanced address book design

Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash

A collection of commonly used plug-ins for idea development tools

Fundamentals of software testing

Software testing learning - day 4

How to write good code - Defensive Programming Guide
随机推荐
【技术随记-08】
c语言中的几个关键字
运动健身的一些心得经验
小程序跳装到公众号
JVM class loading mechanism
Several keywords in C language
460. LFU cache bidirectional linked list
PHP extensions
File contains vulnerabilities (II)
1037 Magic Coupon
5g market trend in 2020
2022-2-15 learning xiangniuke project - Section 8 check login status
VSCode paste image插件保存图片路径设置
centos8安裝mysql8.0.22教程
Software testing learning - day 4
Financial portal related information
492.构造矩形
2022-2-14 learning xiangniuke project - Section 6 displays login information
[whether PHP has soap extensions installed] a common problem for PHP to implement soap proxy: how to handle class' SoapClient 'not found in PHP
Pytorch Chinese document