当前位置:网站首页>Mysql08 (transaction)
Mysql08 (transaction)
2022-07-22 01:25:00 【Happy learning】
Business : Represents a collection of operations , An integral , All or nothing , All or nothing
The beginning of a transaction depends on a DML sentence
/*
The end of the business
1、 natural commit( Make the data modification effective ) perhaps rollback( Restore data to the previous state )
2、 Automatic submission , However, in general, auto submission should be turned off , Efficiency is too low
3、 After the user closes the session , Automatically commit transactions
4、 Rollback transactions when the system crashes or loses power , That is, restore the data to the previous state
*/
insert into emp(empno,ename) values(2222,'zhangsan');
--commit;
--rollback;
select * from emp;
--savepoint Save it
-- When a set of operations contains multiple SQL sentence , But just want to make some of it work , Some part of it fails , At this point, you can use the savepoint
-- At this time, if you need to roll back to a certain state, use rollback to sp1;
delete from emp where empno = 1111;
delete from emp where empno = 2222;
savepoint sp1;
delete from emp where empno = 1234;
rollback to sp1;
commit;
/*
Four characteristics of transactions :ACID
Atomicity : Represents indivisible , A set of operations is either all successful , All or nothing , You can't cut it in the middle
Uniformity : Finally, it is to ensure the consistency of data , When passing by N After multiple operations , The state of the data will not change ( Transfer accounts )
From one consistency state to another , That is, the data can't be disordered
Isolation, : The correlation between transactions has no impact ,( Isolation level )
Strict isolation will reduce efficiency , In some cases, in order to improve the execution efficiency of the program , The level of isolation needs to be reduced
Isolation level :
Read uncommitted
Read submitted
Repeatable
serialize
Data inconsistency :
Dirty reading
It can't be read repeatedly
Fantasy reading
persistence : All data modifications must be persisted to the storage medium , No data loss due to application shutdown
Of the four characteristics , Which is the most critical ?
All features are designed to ensure data consistency , So consistency is the ultimate pursuit
Consistency in transactions is through 、 Isolation, 、 Durability to guarantee
Lock mechanism :
In order to solve the problem of concurrent access , Data inconsistency , Need to lock data
When locking, you need to consider 《 Particle size 》 The problem of :
Object of operation
database
surface
That's ok
In general , The smaller the size of the lock , The more efficient , The larger the particle size , The less efficient
In the actual working environment , Most operations are row level locks
*/
边栏推荐
- 可视化:这十个数据可视化工具软件平台你必须知道
- C#托管资源和非托管资源
- list解析<stl初级> (跑路人笔记)
- Appium自动化框架升级到最新的2.0
- [completion course] development process of IOT / embedded / MCU graduation design project
- malloc 和 空間配置器
- 查看IAR工程所用版本号
- Kaptcha验证码的配置与使用
- Ala-PNA丙氨酸改性PNA肽核酸|Ac-Ala-PNA的合成路线
- A collection of style problems of uniapp applets using the u-view framework
猜你喜欢
传输层协议解析——UDP和TCP
[data analysis 02]
token和session的区别,这个经典面试题值得一个更深入的回答
Selenium被检测为爬虫,怎么屏蔽和绕过
A collection of style problems of uniapp applets using the u-view framework
如何测试webservice接口
【微信小程序】解决代码上传超过大小限制,小程序分包
[rm_ee_note] 2 serial port & remote control
[dongle vulnerability notification] Apache spark command injection vulnerability scheme
Installation du gestionnaire de loisirs
随机推荐
Steve Aoki's Avatar will come to the sandbox metauniverse!
token和session的区别,这个经典面试题值得一个更深入的回答
MongoDB 中的管道操作符($group、$unwind、$sort、$limit、$skip)
Word 2016 strange problem: file save error copy crash
44: Chapter 4: develop file service: 5: integrate fastdfs in [files] file service to realize the logic of [upload avatar]; (including: integrating fastdfs in the project; cross domain issues; creating
Advantages and disadvantages of Tongniu computer room project
Learn the necessary tools of automation selenium think about automated testing in the pit again
JS get the server IP, port and protocol
Share 50 free cloud disk and online disk Services - with unlimited storage space
Can multithreading optimize program performance?
Mysql04 (special train)
Markdown 转 PDF API 数据接口
Oracle笔记 之 空值null的处理
Houdini楼房刚体区域影响破碎笔记
应用层——典型协议解析
Oracle sets the maximum number of connections
[rm_ee_note] 2 serial port & remote control
使用vscode时Tab键缩进从4个空格变为小箭头(已解决)
怎么学自动化测试,可以自学吗?
传输层协议解析——UDP和TCP