当前位置:网站首页>Introduction of MySQL transactions
Introduction of MySQL transactions
2022-07-26 00:20:00 【Camellia——】
-- Business : Manage the whole business operation using things , The execution of the whole transaction is either successful at the same time , Or fail at the same time , If something goes wrong in the middle , Things roll back , The whole thing will fail !
-- ( Regard the whole business operation as a whole , Use things to manage )
-- about DML Addition, deletion and modification of sentences , Default auto submitSELECT @@autocommit;-- Check the status of current things : Automatic submission (1)
-- Simulate transfer operation
-- Create an account table ,id Account No , Self growing primary key
-- name Account name
-- balance amount of money
CREATE TABLE account(
id INT PRIMARY KEY AUTO_INCREMENT,
NAME VARCHAR(10),
balance INT
);
SELECT *FROM account;-- Insert two pieces of data
INSERT INTO account(NAME,balance)VALUES(' Li Si ',1000),(' Wang Wu ',1000);
-- How to start a manual commit transaction start transaction; If there is a problem in the transfer , Roll back :rollback;
-- The whole statement is completed ( If there is no problem ) commit; Commit transaction
START TRANSACTION;
-- Li Si -500
UPDATE account SET balance=balance-500 WHERE id=1;
There is something wrong with the transfer
-- Wang Wu +500
UPDATE account SET balance=balance+500 WHERE id=2;
-- Roll back to the rollback point ( Restore the execution of the business to the initial state )
ROLLBACK;
边栏推荐
- Nest. JS uses express but not completely
- Old laptop becomes server (laptop + intranet penetration)
- Js理解之路:Js常见的6中继承方式
- Binary tree - 110. Balanced binary tree
- redis的使用
- MySQL——主从复制
- Binary tree related knowledge
- Appium中控件元素封装类梳理
- FreeRTOS个人笔记-消息队列
- Prometheus operation and maintenance tool promtool (II) query function
猜你喜欢
![Niuke / Luogu - [noip2003 popularization group] stack](/img/95/871b1c6f492b467bffd25912304b44.gif)
Niuke / Luogu - [noip2003 popularization group] stack

"Demons dance", is the bull market over? 2021-05-13

MySQL - Multi version concurrency control (mvcc)

Backtracking - 77. combination

Duplicate disk: recommended system - negative sampling strategy

MySQL——多版本并发控制(MVCC)
34 use of sparksql custom functions, architecture and calculation process of sparkstreaming, dstream conversion operation, and processing of sparkstreaming docking Kafka and offset

Sequence traversal II of leetcode107 binary tree

Matlab makes the image of serial port output data in real time

FreeRTOS个人笔记-互斥量
随机推荐
试除法--3的幂
How to make your JS code more beautiful
【redis】③ 数据淘汰策略、pipeline 管道命令、发布订阅
Redirection and request forwarding
【目录】mqtt、nodejs项目
Pinduoduo gets the usage instructions of the product details API according to the ID
Under inflation, how to operate in the future? 2021-05-14
网站服务器停止响应是什么意思?
Yes, UDP protocol can also be used to request DNS server
VMware ESXI7.0版本的安装与配置
Binary tree - 530. Minimum absolute difference of binary search tree
This time, thoroughly understand promise principle
Solidity智能合约开发 — 3.2-solidity语法数组、结构体、映射
[hero planet July training leetcode problem solving daily] 25th tree array
数据流通交易场景下数据质量综合管理体系与技术框架研究
12. Neural network model
How to use 120 lines of code to realize an interactive and complete drag and drop upload component?
What is software testing peer review?
Markdown writing platform
二进制表示--2的幂