当前位置:网站首页>Commit and rollback in DCL of 16 MySQL
Commit and rollback in DCL of 16 MySQL
2022-04-23 20:18:00 【gh-xiaohe】
List of articles
author : gh-xiaohe
gh-xiaohe The blog of
If you think the blogger's article is good , I hope you'll make it three times in a row ( Focus on , give the thumbs-up , Comment on ), Give me more support !!
DCL in COMMIT and ROllBACK
DCL in COMMIT and ROllBACK
COMMIT
COMMIT: Submit data . Once executed COMMIT, The data is permanently stored in the database , This means that data cannot be rolled back .
ROLLBACK
ROLLBACK: Undo Data . Once executed ROLLBACK, Data rollback can be realized . Roll back to the most recent COMMIT after .
contrast
- The same thing : All data in the table can be deleted , While preserving the table structure .
- Difference :
- TRUNCATE TABLE: Once you do this , Clear all table data . meanwhile , Data cannot be rolled back .
- DELETE FROM: Once you do this , All table data can be cleared ( No WHERE). meanwhile , Data can be rolled back .
DDL and DML Explanation
① DDL The operation of Once executed , Just Cannot roll back . Instructions SET autocommit = FALSE Yes DDL Operation failure .( Because at the end of execution DDL After the operation , A certain Will execute once COMMIT. And this COMMIT The operation is not affected by SET autocommit = FALSE Affected .)
② DML By default , Once executed , It's also Non rollback . however , If In execution DML Before , Yes SET autocommit = FALSE, Then the execution of DML Operation can realize rollback .
Case study
COMMIT、DELETE
# demonstration :DELETE FROM #1) COMMIT; #2) SELECT * FROM myemp3; #3) SET autocommit = FALSE; #4) DELETE FROM myemp3; #5) SELECT * FROM myemp3; #6) ROLLBACK; #7) SELECT * FROM myemp3;
COMMIT、 ROLLBACK
# demonstration :TRUNCATE TABLE #1) COMMIT; #2) SELECT * FROM myemp3; #3) SET autocommit = FALSE; #4) TRUNCATE TABLE myemp3; #5) SELECT * FROM myemp3; #6) ROLLBACK; #7) SELECT * FROM myemp3;
MySQL8.0 New features :DDL Atomization of
stay MySQL 8.0 In the version ,InnoDB Tabular DDL Support transaction integrity , namely DDL The operation either succeeds or rolls back .DDL Operation rollback log write to data dictionary Data dictionary table mysql.innodb_ddl_log( The table is a hidden table , adopt show tables Can't see ) in , For rollback operations . By setting parameters , Can be DDL Print and output operation log to MySQL In the error log .
Respectively in MySQL 5.7 Version and MySQL 8.0 Create databases and data tables in version , give the result as follows :
CREATE DATABASE mytest; # Create database mytest USE mytest; # Switch to mytest Under database CREATE TABLE book1( # establish book1 surface book_id INT , book_name VARCHAR(255) ); SHOW TABLES; # View the table under the current data
(1) stay MySQL 5.7 In the version , The test steps are as follows :
# stay mysql5.7 Next DROP TABLE book1,book2; # The database is deleted book1 and book2 Notice that there is no book2 SHOW TABLES;
(2) stay MySQL 8.0 In the version , The test steps are as follows :
# stay mysql8.0 Next DROP TABLE book1,book2; # The database is deleted book1 and book2 Notice that there is no book2 SHOW TABLES;
版权声明
本文为[gh-xiaohe]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232017307463.html
边栏推荐
- After route link navigation, the sub page does not display the navigation style problem
- Paper writing 19: the difference between conference papers and journal papers
- How to protect ECs from hacker attacks?
- 本地调用feign接口报404
- Azkaban recompile, solve: could not connect to SMTP host: SMTP 163.com, port: 465 [January 10, 2022]
- [talkative cloud native] load balancing - the passenger flow of small restaurants has increased
- nc基础用法
- Software College of Shandong University Project Training - Innovation Training - network security shooting range experimental platform (8)
- How about CICC fortune? Is it safe to open an account
- Mysql database - connection query
猜你喜欢
Handwritten Google's first generation distributed computing framework MapReduce
Building googlenet neural network based on pytorch for flower recognition
Numpy mathematical function & logical function
如何在BNB鏈上創建BEP-20通證
Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (V)
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
Computing the intersection of two planes in PCL point cloud processing (51)
[talkative cloud native] load balancing - the passenger flow of small restaurants has increased
How to create bep-20 pass on BNB chain
Azkaban recompile, solve: could not connect to SMTP host: SMTP 163.com, port: 465 [January 10, 2022]
随机推荐
R语言使用econocharts包创建微观经济或宏观经济图、indifference函数可视化无差异曲线、自定义计算交叉点、自定义配置indifference函数的参数丰富可视化效果
Sqoop imports tinyint type fields to boolean type
网络通信基础(局域网、广域网、IP地址、端口号、协议、封装、分用)
Investigate why close is required after sqlsession is used in mybatties
考研英语唐叔的语法课笔记
Paper writing 19: the difference between conference papers and journal papers
Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
【目标跟踪】基于帧差法结合卡尔曼滤波实现行人姿态识别附matlab代码
LeetCode动态规划训练营(1~5天)
Zdns was invited to attend the annual conference of Tencent cloud basic resources and share the 2020 domain name industry development report
How to create bep-20 pass on BNB chain
R language uses the preprocess function of caret package for data preprocessing: BoxCox transform all data columns (convert non normal distribution data columns to normal distribution data and can not
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
NC basic usage 1
R语言survival包coxph函数构建cox回归模型、ggrisk包ggrisk函数和two_scatter函数可视化Cox回归的风险评分图、解读风险评分图、基于LIRI数据集(基因数据集)
DNS cloud school | analysis of hidden tunnel attacks in the hidden corner of DNS
How to protect ECs from hacker attacks?
R语言ggplot2可视化分面图(facet_wrap)、使用lineheight参数自定义设置分面图标签栏(灰色标签栏)的高度
Operation of numpy array
DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind