sql 事务提交和回滚_SQL提交和回滚
sql 事务提交和回滚
The most important aspect of a database is the ability to store data and the ability to manipulate data. COMMIT and ROLLBACK are two such keywords which are used in order store and revert the process of data storage. These keywords are usually used in context with a transaction.
数据库最重要的方面是存储数据的能力和处理数据的能力。 COMMIT和ROLLBACK是两个这样的关键字,它们用于顺序存储和还原数据存储过程。 这些关键字通常在事务中使用。
Let’s try to understand the details about COMMIT and ROLLBACK.
让我们尝试了解有关COMMIT和ROLLBACK的详细信息。
SQL提交和回滚 (SQL Commit and Rollback)
COMMIT and ROLLBACK are performed on transactions. A transaction is the smallest unit of work that is performed against a database. Its a sequence of instructions in a logical order. A transaction can be performed manually by a programmer or it can be triggered using an automated program.
COMMIT和ROLLBACK在事务上执行。 事务是针对数据库执行的最小工作单元。 它是逻辑顺序的指令序列。 交易可以由程序员手动执行,也可以使用自动化程序触发。
SQL提交 (SQL Commit)
COMMIT is the SQL command that is used for storing changes performed by a transaction. When a COMMIT command is issued it saves all the changes since last COMMIT or ROLLBACK.
COMMIT是用于存储事务执行的更改SQL命令。 发出COMMIT命令后,它将保存自上一次COMMIT或ROLLBACK以来的所有更改。
SQL提交的语法 (Syntax for SQL Commit)
COMMIT;
The syntax for commit includes just one keyword COMMIT.
commit的语法仅包含一个关键字COMMIT 。
SQL提交示例 (SQL Commit Example)
Let us consider the following table for understanding Commit in a better way.
让我们考虑下表,以更好地理解Commit。
Customer:-
顾客:-
CUSTOMER ID | CUSTOMER NAME | STATE | COUNTRY |
---|---|---|---|
1 | Akash | Delhi | India |
2 | Amit | Hyderabad | India |
3 | Jason | California | USA |
4 | John | Texas | USA |
顾客ID | 顾客姓名 | 州 | 国家 |
---|---|---|---|
1个 | 阿卡什 | 新德里 | 印度 |
2 | 阿米特 | 海得拉巴 | 印度 |
3 | 杰森 | 加利福尼亚州 | 美国 |
4 | 约翰 | 德州 | 美国 |
Now let us delete one row from the above table where State is “Texas”.
现在,让我们从上表中删除状态为“ Texas”的一行。
DELETE from Customer where State = 'Texas';
SQL Delete without Commit
SQL删除没有提交
Post the DELETE command if we will not publish COMMIT, and if the session is closed then the change that is made due to the DELETE command will be lost.
如果我们不发布COMMIT,则发布DELETE命令,并且如果会话关闭,则由于DELETE命令所做的更改将丢失。
Updated Command with COMMIT
使用COMMIT更新命令
DELETE from Customer where State = 'Texas';
COMMIT;
SQL Commit Execution
SQL提交执行
Using the above-mentioned command sequence will ensure that the change post DELETE command will be saved successfully.
使用上述命令序列将确保change post DELETE命令将成功保存。
提交后输出 (Output After Commit)
CUSTOMER ID | CUSTOMER NAME | STATE | COUNTRY |
---|---|---|---|
1 | Akash | Delhi | India |
2 | Amit | Hyderabad | India |
3 | Jason | California | USA |
顾客ID | 顾客姓名 | 州 | 国家 |
---|---|---|---|
1个 | 阿卡什 | 新德里 | 印度 |
2 | 阿米特 | 海得拉巴 | 印度 |
3 | 杰森 | 加利福尼亚州 | 美国 |
Table After SQL Commit
SQL提交后的表
SQL回滚 (SQL RollBack)
ROLLBACK is the SQL command that is used for reverting changes performed by a transaction. When a ROLLBACK command is issued it reverts all the changes since last COMMIT or ROLLBACK.
ROLLBACK是用于还原事务执行的更改SQL命令。 发出ROLLBACK命令时,它将还原自上次COMMIT或ROLLBACK之后的所有更改。
SQL回滚的语法 (Syntax for SQL Rollback)
ROLLBACK;
The syntax for rollback includes just one keyword ROLLBACK.
回滚的语法仅包含一个关键字ROLLBACK 。
SQL回滚示例 (SQL Rollback Example)
Let us consider the following table for understanding Rollback in a better way.
让我们考虑下表,以更好地理解回滚。
Customer:-
顾客:-
CUSTOMER ID | CUSTOMER NAME | STATE | COUNTRY |
---|---|---|---|
1 | Akash | Delhi | India |
2 | Amit | Hyderabad | India |
3 | Jason | California | USA |
4 | John | Texas | USA |
顾客ID | 顾客姓名 | 州 | 国家 |
---|---|---|---|
1个 | 阿卡什 | 新德里 | 印度 |
2 | 阿米特 | 海得拉巴 | 印度 |
3 | 杰森 | 加利福尼亚州 | 美国 |
4 | 约翰 | 德州 | 美国 |
Now let us delete one row from the above table where State is “Texas”.
现在,让我们从上表中删除状态为“ Texas”的一行。
DELETE from Customer where State = 'Texas';
SQL Delete without Rollback
SQL删除而无需回滚
Post the DELETE command if we publish ROLLBACK it will revert the change that is performed due to the delete command.
如果发布ROLLBACK,则发布DELETE命令,它将恢复由于delete命令而执行的更改。
Updated Command with ROLLBACK
使用ROLLBACK更新了命令
DELETE from Customer where State = 'Texas';
ROLLBACK;
SQL Delete with Rollback
带回滚SQL删除
Using the above-mentioned command sequence will ensure that the change post DELETE command will be reverted successfully.
使用上述命令序列将确保change post DELETE命令将被成功还原。
回滚后输出 (Output After Rollback)
CUSTOMER ID | CUSTOMER NAME | STATE | COUNTRY |
---|---|---|---|
1 | Akash | Delhi | India |
2 | Amit | Hyderabad | India |
3 | Jason | California | USA |
4 | John | Texas | USA |
顾客ID | 顾客姓名 | 州 | 国家 |
---|---|---|---|
1个 | 阿卡什 | 新德里 | 印度 |
2 | 阿米特 | 海得拉巴 | 印度 |
3 | 杰森 | 加利福尼亚州 | 美国 |
4 | 约翰 | 德州 | 美国 |
Table after executing Rollback
执行回滚后的表
翻译自: https://www.journaldev.com/23932/sql-commit-sql-rollback
sql 事务提交和回滚
sql 事务提交和回滚_SQL提交和回滚相关推荐
- sql事务提交回滚命令_提交,回滚和保存点SQL命令
sql事务提交回滚命令 Transaction Control Language(TCL) commands are used to manage transactions in the databa ...
- Oracle数据库事务回滚和提交,数据库 事务提交和回滚
事务 - (transaction / tx) 原子性操作性(不可以分割的操作) - 要么全做, 要么全不做 事务的特点 - ACID 特性 A - atomicity 原子性 : 不可分割 ...
- MySQL:事务:开启、回滚与提交
这里,我们使用 set session autocommit=0,修改当前会话的事务提交方式.autocommit变量有两个可选值:ON与OFF,ON代表事务是自动提交,OFF代表不自动提交.roll ...
- mysql 事务回滚语句_数据库事务回滚语句-sql事务回滚语句是-用于事务回滚的sql语句...
sql 回滚语句 这种情况的数据恢复只能利用事务日志的备份来进行,所以如果你的SQL没有进行相应的全库备份 或不能备份日志(truncate log on checkpoint选项为1),那幺就无法进 ...
- SVN 撤回(回滚)提交的代码
转: SVN 撤回(回滚)提交的代码 2016年12月20日 17:20:58 怀色 阅读数 68614 标签: svn svn回滚 版本回滚 更多 个人分类: svn 版权声明:本文为博主原创文章, ...
- 【Git】Git 基础命令 ( 查看提交记录 git log | 版本回滚 git reset | 撤销回滚 git reflog )
文章目录 一.查看提交记录 git log 1.查看详细提交记录 2.查看简略提交记录 二.版本回滚 git reset 1.Git 中的版本表示 HEAD~1 2.版本库代码回滚 三.撤销回滚 1. ...
- git reset revert 回退回滚取消提交返回上一版本
总有一天你会遇到下面的问题. (1)改完代码匆忙提交,上线发现有问题,怎么办? 赶紧回滚. (2)改完代码测试也没有问题,但是上线发现你的修改影响了之前运行正常的代码报错,必须回滚. 这些开发中很常见 ...
- [转]SQL事务回滚的问题及其解决的方法
[转]SQL事务回滚的问题及其解决的方法 原文:http://shirlly.javaeye.com/blog/370973 Begin Transaction:开始一个事务: Commit Tran ...
- git revert回滚merge提交时报错(commit xxx is a merge but no -m option )
git revert 回滚merge提交 报错内容: $ git revert 788bab4 error: commit 788bab4021fe14db3a0865aa55fd1b798b74c2 ...
最新文章
- transformer bert seq2seq 深度学习 编码和解码的逻辑-重点
- java 内存测试_请你说一下java jvm的内存机制
- 程序猿生存指南-35 王旭新巢
- Android日期分组,按查询分组在列表视图android中显示一些意...
- sam格式的结构和意义_SAM格式的学习
- 只用两个函数实现事务的设计模式!
- html鼠标感应图片,jQuery实现的感应鼠标悬停图片色彩渐显效果
- 大学生html作业总结,总结 HTML标签作业
- POJ-1149(网络流)
- mfc用数组怎么存储句柄_指南手机存储不足怎么办?用好这份清理指南你的手机还能再战三年...
- TeamWork#3,Week5,The First Meeting of Our Team
- 材料成型过程计算机控制系统,材料成型及控制工程专业解读_材料成型及控制工程专业介绍_材料成型及控制工程专业开设课程-高考圈...
- 【踩坑】XML转JSON中如何把单个元素转成数组
- 学习某一门技术的步骤(韩顺平老师提供)
- 不用光盘和u盘怎么重装系统win10
- C语言之:数组的定义和初始化必备练习题
- 2021年HECTF部分Writeup
- 软件测试和硬件测试的区别及概念
- Flutter弹起键盘页面布局超限问题以及布局上移问题
- 物联网学习笔记(一)