当前位置:网站首页>TCL statements in SQL (transaction control statements)
TCL statements in SQL (transaction control statements)
2022-07-01 06:27:00 【HHYZBC】
Catalog
How to do multiple transactions DML What about statements that succeed and fail at the same time ?
The business includes 4 A feature
TCL Statement represents the transaction control language
- commit
- Transaction submission
- rollback
- Transaction rollback
Although there are only two statements , But it's connected MySQL A very important point in : Business .
Business
A transaction is actually a complete business logic . Is the smallest unit of work . Can not be further divided .
Only DML Statement will have the statement of transaction , Other statements have nothing to do with transactions !!!
- insert
- delete
- update
Only the above three statements are related to transactions , Nothing else matters .
because Only the above three statements add data in the database table 、 Delete 、 Changed . As long as your operation involves the increase of data 、 Delete 、 Change , Then we must consider the safety issue .
Data security comes first !!!
How to do multiple transactions DML What about statements that succeed and fail at the same time ?
stay InnoDB Storage engine : Provides a set of log files used to record transactional activities . During the execution of a transaction , Every one of them DML All operations will be recorded in “ Log files for transactional activities ” in . During the execution of a transaction , We can commit transactions , Transactions can also be rolled back .
Commit transaction
Clear the log file of transactional activities , Completely persist all data into database tables . Committing a transaction marks , The end of the business . And it's the end of all success .
Input commit Command means commit transaction
mysql Automatic transaction submission is supported by default . And by default , Every time you execute one DML sentence , Then submit once !
Input start transaction; The auto commit mechanism can be turned off
Roll back the transaction
All the previous DML Undo all operations , And clearing the log files of transactional activities and rolling back transactions marks , The end of the business . And it's the end of all failure .
Input rollback Command means rollback transaction ( Rollback can only be rolled back to the last commit point !)
The business includes 4 A feature
abbreviation ACIB
- Atomicity
- It shows that transaction is the smallest unit of work . Can not be further divided .
- Uniformity
- All transactions require , In the same transaction , All operations must be successful at the same time , Or fail at the same time , To ensure data consistency .
- Isolation,
- A Business and B There is some isolation between transactions . classroom A And classroom B There is a wall between , This wall is isolation .A When a transaction operates on a table , Another business B If you also operate this table, it will be like that ???
- persistence
- A guarantee of the end of the transaction . Transaction submission , It is equivalent to saving data not saved to the hard disk to the hard disk !
Isolation,
Isolation has come again 4 A level
- Read uncommitted :read uncommitted( Lowest isolation level )
- It's a business A Can read to transaction B Uncommitted data . To put it simply, I didn't submit my study
- The problem with this isolation level is : Dirty reading !(Dirty Read) We said we read dirty data .
- This level of isolation is generally theoretical , Most database isolation levels are second-class !
- Read submitted :read committed
- It's a business A Only transactions can be read B Data after submission . Simply put, you can only read after submitting
- Solved the phenomenon of dirty reading . However, there is a problem that data cannot be read repeatedly
- After the transaction is opened , The first data read is 3 strip , The current transaction is not over yet , Maybe the second time I read it again , The data read is 4 strip ,3 It's not equal to 4 It is called non repeatable read .
- This level of isolation is more real data , The data read every time is absolutely true .
- oracle The default isolation level of the database is :read committed
- Repeatable :repeatable read
- Business A After opening , No matter how long , Every time in business A The data read in is consistent . Even if the business B The data has been modified , And submitted , Business A The read data still hasn't changed , This is repeatable reading . Simply put, you can't read it after submitting , Always read the data when the transaction was just started
- It solves the problem of non repeatable data reading . But phantom reading may occur . Every time the data is read, it is an illusion . Not true enough !
- mysql This is the default transaction isolation level in !!!!!!!!!!!
- serialize :serializable( Highest isolation level )
- Also called serialization
- This is the highest isolation level , Minimum efficiency . Solved all the problems .
- This isolation level indicates that transactions are queued , Can't be concurrent !
- The data read every time is the most real , And the efficiency is the lowest .
- Also called serialization
边栏推荐
- 微信公众号内嵌跳转微信小程序方案总结
- 阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]
- High order binary search tree
- [file system] how to run squashfs on UBI
- sci-hub如何使用
- 阶乘约数(唯一分解定理)
- [ManageEngine] how to realize network automatic operation and maintenance
- 【ManageEngine】终端管理系统,助力华盛证券数字化转型
- 【ManageEngine卓豪】网络运维管理是什么,网络运维平台有什么用
- Uniapp tree level selector
猜你喜欢

Detailed steps for installing redis on Windows system
![[ITSM] what is ITSM and why does it department need ITSM](/img/e1/85b5f00f124829b6a6b40c5cf621bd.png)
[ITSM] what is ITSM and why does it department need ITSM

Top 10 Free 3D modeling software for beginners in 2022

手把手教你实现一个深度学习框架...

SystemVerilog learning-10-validation quantification and coverage

C语言课设学生考勤系统(大作业)

B-tree series

On siem

【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】

HCM Beginner (IV) - time
随机推荐
[ITSM] what is ITSM and why does it department need ITSM
Elements of database ER diagram
Diffusion (multi-source search)
Using Baidu map to query national subway lines
阶乘约数(唯一分解定理)
Picture server project test
JMM详解
【LeetCode】Day91-存在重复元素
【ManageEngine卓豪 】助力世界顶尖音乐学院--茱莉亚学院,提升终端安全
Understanding of C manualresetevent class
【ManageEngine卓豪】局域网监控的作用
Pychart configuring jupyter
kubeadm搭建kubenetes 集群(个人学习版)
Self confidence is indispensable for technology
地宫取宝(记忆化深搜)
[ManageEngine Zhuohao] the role of LAN monitoring
启牛学堂合作的证券公司是哪家?开户安全吗?
子类调用父类的同名方法和属性
Dongle data collection
JDBC database operation