当前位置:网站首页>transaction, storage engine
transaction, storage engine
2022-08-10 05:46:00 【hagong9】
目录
Demonstration of the operation of things
The isolation level within a transaction编辑
What is the use of things?
如上图,It is no problem to use previous knowledge to achieve this requirement,但是如果出现了 The first statement executes successfully,The second statement does not succeed,Then it will disappear out of thin air100元 ,To avoid this problem,These two statements should be turned into a set of statements,要么都成功,要么都失败.It's time to use things to solve it.
Demonstration of the operation of things
-- Demonstration of the operation of things
-- 1,Create a demo sheet
CREATE TABLE demo
(id INT,
`name` VARCHAR(10))
-- 2.开始事物
START TRANSACTION
-- 3.设置保存点
SAVEPOINT a
-- 4 dml操作
INSERT INTO demo
VALUES (1,'张三')
-- 5,Set a second savepoint
SAVEPOINT b
-- 6.再执行dml操作,Insert one more message here
INSERT INTO demo
VALUES (2,'李四')
-- 7.Check the current onedemo表
SELECT * FROM demo
】
Roll back to a savepoint
-- 8.回退到保存点b
ROLLBACK TO b
-- 9.再次查询demo表
SELECT * FROM demo
This save point is similar to the save point of the game,Select the desired archive to read.
Among them, if there is a situation that cannot be reversed,Is because the engine of the table is notINNODB It needs to be specified when creating the table or changed in the design table.
details of things
The isolation level within a transaction
简单解释,There are now two connections,A和B
Two people start things,AConnect to modify the database,但未提交,这时BQuery the database,结果读到了A修改的数据,这就是脏读.
AModify and delete databases(插入),也提交了,但是bNot submitting your own,正常情况下BWhat you should see is the database data when you started things,As a result, when you query the database, what you see is aAffected database,这就是不可重复读.(幻读).
Locked means,Only one connection can overrun the database at a time,比如,A对数据库进行修改,但是未提交,这时B查询数据库,will get stuck on the query statement,不执行
设置隔离级别
事物ACID
存储引擎
使用show engines to see all engines
使用 alter table `表名` engines = xxxxx to modify the engine of the table
Main engine characteristics
边栏推荐
猜你喜欢
随机推荐
pytorch框架学习(5)torchvision模块&训练一个简单的自己的CNN (二)
ORACLE系统表空间SYSTEM占满无法扩充表空间问题解决过程
Qiskit 学习笔记2
链读精选:星巴克着眼于数字收藏品并更好地吸引客户
Database Notes Create Database, Table Backup
tinymce富文本编辑器
视图【】【】【】【】
各个架构指令集对应的机型
数据库 笔记 创建数据库、表 备份
文本元素
链读推荐:从瓷砖到生成式 NFT
WSTP初体验
Count down the six weapons of the domestic interface collaboration platform!
IDEA的database使用教程(使用mysql数据库)
非会员更改有道云笔记背景
Notes 1
redis常见的面试题
基于Qiskit——《量子计算编程实战》读书笔记(五)
【yolov5训练错误】WARNING: Ignoring corrupted image
pytest测试框架