当前位置:网站首页>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
边栏推荐
- 【Unity Shader 消融效果_案例分享】
- [postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map
- make: g++:命令未找到
- idea 好用插件汇总!!!
- Projects and dependencies in ABP learning solutions
- 【#Unity Shader#自定义材质面板_第一篇】
- 阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]
- 【ManageEngine卓豪】移动终端管理解决方案,助力中州航空产业数字化转型
- 做技术,自信不可或缺
- Dongle data collection
猜你喜欢

【网络安全工具】USB控制软件有什么用

SystemVerilog learning-08-random constraints and thread control

【自动化运维】自动化运维平台有什么用

自开发软件NoiseCreater1.1版本免费试用

async 与 await
![[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform](/img/14/756d566744d6e4a988a284c5b30130.png)
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform

VS2019如何永久配置本地OpenCV4.5.5使用

HCM Beginner (I) - Introduction
![[ManageEngine] how to realize network automatic operation and maintenance](/img/8a/75332d3180f92c6a6482d881032bbf.png)
[ManageEngine] how to realize network automatic operation and maintenance

Top 10 Free 3D modeling software for beginners in 2022
随机推荐
Tidb database characteristics summary
C language course set up property fee management system (big work)
[ManageEngine Zhuohao] helps Huangshi Aikang hospital realize intelligent batch network equipment configuration management
Elements of database ER diagram
Forkjoin and stream flow test
ManageEngine卓豪助您符合ISO 20000标准(四)
网络爬虫
SystemVerilog learning-10-validation quantification and coverage
Diffusion (multi-source search)
C语言课设工资管理系统(大作业)
【ManageEngine卓豪 】助力世界顶尖音乐学院--茱莉亚学院,提升终端安全
SystemVerilog learning-08-random constraints and thread control
Code power is full of quantitative learning | how to find a suitable financial announcement in the financial report
Understanding of C manualresetevent class
【ManageEngine卓豪】移动终端管理解决方案,助力中州航空产业数字化转型
Discrimination between left and right limits of derivatives and left and right derivatives
MongoDB:一、MongoDB是什么?MongoDB的优缺点
连续四年入选Gartner魔力象限,ManageEngine卓豪是如何做到的?
HDU - 1501 zipper (memory deep search)
做技术,自信不可或缺