当前位置:网站首页>Database transaction Transanction
Database transaction Transanction
2022-06-24 22:42:00 【Passerby Chen】
What is business transanction ?
Business , A logical set of operations , The units that make up this set of operations are either all successful , All or nothing .
The role of affairs : Ensure that a set of operations all succeed or fail .
Business (transanction) Four characteristics of ( ACID ): Atomicity (Atomicity)、 Uniformity (Correspondence)、 Isolation, (Isolation)、 persistence (Durability).
Atomicity (Atomicity) | All operations in the whole transaction , Or it's all done , Or not at all , It's impossible to stop in the middle | Or they all succeed , Or they all fail |
Uniformity (Correspondence) | Before and after transaction start , The database integrity constraint is not broken | The integrity of the data before and after the transaction must be consistent |
Isolation, (Isolation) | Isolated state execution transactions , Make them seem like the only operations that the system performs at a given time | Transactions do not interfere with each other |
persistence (Durability) | After the transaction is completed , Changes made by the firm to the database are persisted in the database , It will not be rolled back | Persistence means that once a transaction is committed , It changes the data in the database permanently |
How things work

Four isolation levels of transactions
| Level | name | Isolation level | Dirty reading | It can't be read repeatedly | Fantasy reading | Database default isolation level |
|---|---|---|---|---|---|---|
| 1 | Read uncommitted | read uncommitted | yes | yes | yes | |
| 2 | Read submitted | read committed | no | yes | yes | Oracle |
| 3 | Repeatable | repeatable read | no | no | yes | MySQL |
| 4 | Serialization | serializable | no | no | no |


Set isolation level
Query the current transaction isolation level
select @@tx_isolation;
Set the transaction isolation level
set session transaction isolation level Isolation level ; eg: Set the transaction isolation level to :read uncommitted,read committed,repeatable read,serializable eg: set session transaction isolation level read uncommitted;
Manual transaction management
Mode one : The way to manually start a transaction 【 master 】
start transaction; Open transaction
commit; Submit
rollback; Roll back-- scene : zs towards ls Transfer accounts 100 element -- No abnormal -- Open transaction start transaction; -- zs money -100 update account set money = money - 100 where name = 'zs'; -- ls money +100 update account set money = money + 100 where name = 'ls'; -- Commit transaction commit; -- There are abnormal -- Open transaction start transaction; -- zs money -100 update account set money = money - 100 where name = 'zs'; -- An exception may occur here -- ls money +100 update account set money = money + 100 where name = 'ls'; -- Roll back the transaction rollback; -- Committing a transaction or rolling back a transaction will end the transaction
Mode two : Set up MYSQL Auto submit parameters in 【 understand 】
see MYSQL Whether the transaction is automatically committed in
show variables like '%commit%';Set the parameter of automatic submission as OFF
set autocommit = 0; //0:OFF 1:ON
边栏推荐
- [personal experiment report]
- Firewall working principle and detailed conversation table
- The usage difference between isempty and isblank is so different that so many people can't answer it
- Heartless sword Chinese English bilingual poem 003 The sea of books
- Publicity of the second batch of shortlisted enterprises! Annual Top100 smart network supplier selection
- Redis hop table
- [QT] QT event handling
- Servlet details
- Leetcode: calculate the number of elements less than the current element on the right (sortedlist+bisect\u left)
- String exercise summary 2
猜你喜欢
随机推荐
详细了解关于sentinel的实际应用
FANUC机器人_KAREL编程入门学习(1)
Docker installs redis-5.0.12. Detailed steps
【軟件工程】期末重點
Creating files, recursively creating directories
【Mongodb】READ_ME_TO_RECOVER_YOUR_DATA,数据库被恶意删除
Leetcode: calculate the number of elements less than the current element on the right (sortedlist+bisect\u left)
Information update on automatic control principle
VRRP skills topic
Valueerror: cannot take a larger sample than population when 'replace=false‘
中国SSD行业企业势力全景图
源码阅读 | OpenMesh读取文本格式stl的过程
04A interrupt configuration
How to compare two or more distributions: a summary of methods from visualization to statistical testing
磁盘的结构
Data communication and physical network
2022-06-16 work record --js- judge the number of digits in string type digits + judge the number of digits in numeric type digits + limit the text length (display n words at most, exceeding...)
The usage difference between isempty and isblank is so different that so many people can't answer it
CDN principle
Principle of IP routing








