当前位置:网站首页>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;
边栏推荐
- 关于“DBDnet: A Deep Boosting Strategy for ImageDenoising“一文理解
- 什么是 Web3 游戏?
- 二进制表示--2的幂
- OPENCV学习DAY6
- Opencv learning Day6
- nodejs启动mqtt服务报错SchemaError: Expected `schema` to be an object or boolean问题解决
- IP Core: PLL
- The bull market is not over yet, and there is still 2021-05-18 in the second half
- Solidity智能合约开发 — 3.2-solidity语法数组、结构体、映射
- How long can this bull market last Answers to questions 2021-05-11
猜你喜欢

基于网络分析和文本挖掘的意见领袖影响力研究

CountDownLatch

软件测试同行评审到底是什么?

nodejs启动mqtt服务报错SchemaError: Expected `schema` to be an object or boolean问题解决

二进制表示--2的幂

How long can this bull market last Answers to questions 2021-05-11

IP核:PLL
34 use of sparksql custom functions, architecture and calculation process of sparkstreaming, dstream conversion operation, and processing of sparkstreaming docking Kafka and offset

The way to understand JS: the principle of object.call and object.create() inheritance

OPENCV学习DAY6
随机推荐
redis的使用
Solidity智能合约开发 — 3.2-solidity语法数组、结构体、映射
Nest.js 用了 Express 但也没完全用
【目录】mqtt、nodejs项目
牛血清蛋白修饰酚酸类及生物碱类小分子/偶联微球的蛋白/牛红细胞SOD的研究
SSM environment integration
Flask发送验证码逻辑
MPLS实验
FreeMarker view integration
What are the precautions for using MySQL index? (answer from six aspects)
VMware ESXI7.0版本的安装与配置
Leetcode high frequency question 66. add one, give you an array to represent numbers, then add one to return the result
appium 从启动到测试再到结束流程梳理
Js理解之路:什么是原型链
MPLS中的包交换和标签交换
bond网卡模式配置
FreeRTOS personal notes - semaphore
MPLS experiment
基于MFFMB的电商评论文本分类研究
mysql事务的四大特性以及隔离级别