当前位置:网站首页>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
边栏推荐
- Although pycharm is marked with red in the run-time search path, it does not affect the execution of the program
- C语言课设学生考勤系统(大作业)
- Ant new village is one of the special agricultural products that make Tiantou village in Guankou Town, Xiamen become Tiantou village
- Mysql 表分区创建方法
- Kubedm builds kubenetes cluster (Personal Learning version)
- [ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security
- JMM details
- 三分钟带你快速了解网站开发的整个流程
- Redis安装到Windows系统上的详细步骤
- 【网络安全工具】USB控制软件有什么用
猜你喜欢
【网络安全工具】USB控制软件有什么用
【ManageEngine卓豪】网络运维管理是什么,网络运维平台有什么用
Tidb database characteristics summary
High order binary balanced tree
C语言课设销售管理系统设计(大作业)
Tidb single machine simulation deployment production environment cluster (closed pit practice, personal test is effective)
Picture server project test
【ITSM】什么是ITSM,IT部门为什么需要ITSM
HCM Beginner (III) - quickly enter pa70 and pa71 to browse employee information PA10
SystemVerilog learning-10-validation quantification and coverage
随机推荐
Projects and dependencies in ABP learning solutions
ForkJoin和Stream流测试
阶乘约数(唯一分解定理)
json模块
C语言课设物业费管理系统(大作业)
Make: g++: command not found
基金定投是高风险产品吗?
【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】
HCM Beginner (IV) - time
[enterprise data security] upgrade backup strategy to ensure enterprise data security
端口扫描工具对企业有什么帮助?
做技术,自信不可或缺
Distributed lock implementation
High order binary balanced tree
XAF Bo of dev XPO comparison
[ManageEngine Zhuohao] what is network operation and maintenance management and what is the use of network operation and maintenance platform
证券类开户有什么影响 开户安全吗
Teach you how to implement a deep learning framework
golang panic recover自定义异常处理
[ManageEngine Zhuohao] helps Huangshi Aikang hospital realize intelligent batch network equipment configuration management