当前位置:网站首页>The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
2022-04-23 18:54:00 【loveCC_ orange】
Business
- Business profile
- The transaction operations
- Four characteristics of transaction
- Concurrent transaction problems
- Transaction isolation level
A transaction is a collection of operations , It is an indivisible unit of work , The transaction will submit or revoke the operation request to the system as a whole , That is, these operations either succeed at the same time , Or fail at the same time .






-- --------------------------------- The transaction operations -----------------------------------------
-- Data preparation
create table account(
id int auto_increment primary key comment ' Primary key ID',
name varchar(10) comment ' full name ',
money int comment ' balance '
) comment ' Account form ';
insert into account(id, name, money) VALUES (null, ' Zhang San ', 2000), (null, ' Li Si ', 2000);
-- Restore data
update account set money = 2000 where name = ' Zhang San ' or name = ' Li Si ';
select @@autocommit;
set @@autocommit = 1; -- Set to manual submit
-- Transfer operation ( Zhang San gives Li sizhuan 1000)
-- 1. Check the balance of Zhang San
select * from account where name = ' Zhang San ';
-- 2、 Reduce the balance of Zhang San by 1000
update account set money = money - 1000 where name = ' Zhang San ';
-- 3、 Add... To the balance of Li Si 1000
update account set money = money + 1000 where name = ' Li Si ';
-- Commit transaction
commit ;
-- Roll back the transaction
rollback ;
-- Mode two
-- Transfer operation ( Zhang San transfers money to Li Si 1000)
start transaction ;
-- 1、 Check the balance of Zhang San
select * from account where name = ' Zhang San ';
-- 2、 Leave three balances -1000
update account set money = money - 1000 where name = ' Zhang San ';
-- 3、 Balance of Li Si +1000
update account set money = money + 1000 where name = ' Li Si ';
-- Commit transaction
commit ;
-- Roll back the transaction
rollback ;
-- Four characteristics of transactions
-- Atomicity
-- Uniformity
-- Isolation,
-- persistence
-- Concurrent transaction problems
-- The isolation level of the transaction
-- View transaction isolation level
select @@transaction_isolation;
-- Set the transaction isolation level
set session transaction isolation level read uncommitted;
set session transaction isolation level repeatable read ;
版权声明
本文为[loveCC_ orange]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231849152791.html
边栏推荐
- Esp32 drive encoder -- siq-02fvs3 (vscade + IDF)
- 在渤海期货办理开户安全吗。
- 使用晨曦记账本,分析某个时间段每个账户收支结余
- ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
- 关于unity文件读取的操作(一)
- Coolweather is revised and connected to the wind weather interface to realize the broken line diagram of temperature
- ESP32 LVGL8. 1 - textarea text area (textarea 26)
- MySQL statement
- Nacos cluster construction and MySQL persistence configuration
- Machine learning practice - naive Bayes
猜你喜欢

Solutions such as unknown or garbled code or certificate problem prompt in Charles's mobile phone packet capture, actual measurement.

12个例子夯实promise基础

MySQL学习第五弹——事务及其操作特性详解

iptables -L执行缓慢

2022.04.23(LC_763_划分字母区间)

7、 DOM (Part 2) - chapter after class exercises and answers

The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an

从技术体系到商业洞察,中小研发团队架构实践之收尾篇

Druid SQL和Security在美团点评的实践

ESP32 LVGL8. 1 - textarea text area (textarea 26)
随机推荐
Go 语言 GUI 框架 fyne 中文乱码或者不显示的问题
Nacos集群搭建和mysql持久化配置
ESP32 LVGL8. 1 - img picture (IMG 20)
Teach you to quickly rename folder names in a few simple steps
Machine learning practice - naive Bayes
[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
Yyds dry goods inventory stringprep --- Internet string preparation
7、 DOM (Part 2) - chapter after class exercises and answers
2022.04.23(LC_714_买卖股票的最佳时机含手续费)
MVVM模型
ESP32 LVGL8. 1 - bar progress bar (bar 21)
The corresponding permissions required to automatically open the app in the setting interface through accessibility service
: app: transformclasseswithrobustfordevrease meituan hot repair compilation error record
STM32: LCD显示
Eight bit binary multiplier VHDL
12个例子夯实promise基础
Recyclerview control list item layout match_ Fundamental principle of parent attribute invalidation
MySQL statement
Configure iptables
Résolution: cnpm: impossible de charger le fichier... Cnpm. PS1 parce que l'exécution de scripts est désactivée sur ce système