当前位置:网站首页>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
边栏推荐
- SQL中函数 decode()与 replace()的用法
- 22年字节跳动飞书人力套件三面面经
- Usage of functions decode() and replace() in SQL
- About the operation of unit file reading (I)
- 在渤海期货办理开户安全吗。
- Sogou cell thesaurus analysis (only extract words and word frequency)
- One of the reasons why the WebView web page cannot be opened (and some WebView problem records encountered by myself)
- RPM包管理
- MySQL学习第五弹——事务及其操作特性详解
- ESP32 LVGL8. 1 - calendar (calendar 25)
猜你喜欢
mysql_ Download and installation of Linux version
微搭低代码零基础入门课(第三课)
ctfshow-web362(SSTI)
根据快递单号查询物流查询更新量
Esp32 (UART receiving and sending) - receiving and sending communication of serial port (4)
解决:cnpm : 无法加载文件 ...\cnpm.ps1,因为在此系统上禁止运行脚本
昇腾 AI 开发者创享日全国巡回首站在西安成功举行
【历史上的今天】4 月 23 日:YouTube 上传第一个视频;网易云音乐正式上线;数字音频播放器的发明者出生
Druid SQL和Security在美团点评的实践
Chondroitin sulfate in vitreous
随机推荐
mysql_linux版本的下载及安装详解
【C语言进阶11——字符和字符串函数及其模拟实现(2))】
Actual combat of Nacos as service configuration center
iptables初探
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
How about CICC wealth? Is it safe to open an account up there
STM32: LCD显示
7、 DOM (Part 2) - chapter after class exercises and answers
Practice of Druid SQL and security in meituan review
【数学建模】—— 层次分析法(AHP)
微搭低代码零基础入门课(第三课)
An 8266 crash
Nacos作为服务配置中心实战
Screenshot using projectmediamanager
Yyds dry goods inventory stringprep --- Internet string preparation
机器学习理论基础篇--关于机器学习的一些术语
WebView saves the last browsing location
ESP32 LVGL8. 1 - img picture (IMG 20)
ctfshow-web362(SSTI)
Nacos cluster construction and MySQL persistence configuration