sql事务转账的sql语句_SQL事务

sql事务转账的sql语句

SQL | 交易次数 (SQL | Transactions)

A transaction may be a unit of labor that's performed against a database. A transaction is the propagation of one or more changes to the database. For instance, if you're creating a record or updating a record or deleting a record from the table, then you're performing a transaction there on the table. It's important to regulate these transactions to make sure the info integrity and to handle database errors.

事务可能是针对数据库执行的工作单位。 事务是将一个或多个更改传播到数据库。 例如,如果您要创建记录,更新记录或从表中删除记录,那么您将在表上执行事务 。 规范这些事务以确保信息完整性并处理数据库错误很重要。

Practically, we'll club many SQL queries into a gaggle and we'll execute all of them together as a neighborhood of a transaction.

实际上,我们会将许多SQL查询合并到一个小工具中,并将它们作为事务的邻域一起执行。

交易性质 (Properties of Transaction)

PropertiesDescription
AtomicityIt guarantees that all activities inside the work unit are finished effectively. Otherwise, the exchange is prematurely ended at the purpose of disappointment and all the past activities are moved back to their previous state.
ConsistencyIt guarantees that the database appropriately changes states upon an effectively dedicated exchange.
IsolationIt empowers exchanges to work autonomously and straightforward to one another.
DurabilityIt makes sure that the changes of a committed transaction remain in case of a system failure.
物产 描述
原子性 它保证了工作单元内的所有活动均有效完成。 否则,交换会出于失望的目的而提前结束,并且所有过去的活动都将恢复到以前的状态。
一致性 它保证数据库在有效的专用交换后适当地更改状态。
隔离 它使交易所能够彼此独立自主地工作。
耐用性 它确保在系统故障的情况下保留已提交事务的更改。

交易中使用的命令 (Commands Used in Transaction)

Value-based control orders are just utilized with the DML Commands, for example, - INSERT, UPDATE and DELETE as it were. While making tables or dropping them we cannot use these commands.

基于值的控制命令仅与DML命令一起使用 ,例如-INSERTUPDATEDELETE 。 在创建表或删除表时,我们无法使用这些命令。

SQL Transactions

1)COMMIT命令 (1) The COMMIT Command)

The COMMIT order is the value-based order used to spare changes summoned by an exchange to the database.

COMMIT订单是基于值的订单,用于保留通过交换而召集到数据库的更改。

The COMMIT order is the value-based order used to spare changes conjured by an exchange to the database. The COMMIT order spares all the exchanges to the database since the last COMMIT or ROLLBACK order.

COMMIT订单是基于价值的订单,用于节省由于交换而导致的对数据库的更改。 自上一个COMMITROLLBACK指令以来, COMMIT指令将所有交换保留到数据库中。

The language structure for the COMMIT order is as per the following.

COMMIT命令的语言结构如下。

COMMIT;

Example:

例:

We will consider the following STUDENT table:

我们将考虑以下学生表:

IDNAMEPhone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
ID 名称 电话号码。 百分
12 Sanyam Gupta 5652156415 79%
43 Divyam Singh 1522141252 85%
76 迪亚·辛哈(Diya Sinha) 4788471154 77%
88 Prabhjeet Singh 9875545566 92%
70 Preena Rajora 8700997912 65%

The following example will delete a record of a student having a percentage 65 and COMMIT the changes in the database.

下面的示例将删除一个学生的记录,该学生的百分比为65,并在数据库中提交更改。

DELETE FROM STUDENT
WHERE percent=65%;
COMMIT;

We will get the following result:

我们将得到以下结果:

IDNAMEPhone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
ID 名称 电话号码。 百分
12 Sanyam Gupta 5652156415 79%
43 Divyam Singh 1522141252 85%
76 迪亚·辛哈(Diya Sinha) 4788471154 77%
88 Prabhjeet Singh 9875545566 92%

2)ROLLBACK命令 (2) The ROLLBACK Command)

The ROLLBACK order is the value-based order used to fix exchanges that have not as of now been spared to the database. This order must be utilized to fix exchanges since the last COMMIT or ROLLBACK order was given.

ROLLBACK顺序是基于值的顺序,用于修复到目前为止尚未保存到数据库的交换。 自从给出最后一个COMMITROLLBACK命令以来,必须利用此命令来固定交换。

The punctuation for a ROLLBACK order is as per the following.

ROLLBACK顺序的标点如下。

ROLLBACK;

Consider the following data table:

考虑以下数据表:

IDNAMEPhone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
ID 名称 电话号码。 百分
12 Sanyam Gupta 5652156415 79%
43 Divyam Singh 1522141252 85%
76 迪亚·辛哈(Diya Sinha) 4788471154 77%
88 Prabhjeet Singh 9875545566 92%
70 Preena Rajora 8700997912 65%

Here if we will first delete the record then will use the ROLLBACK command to get back the data deleted.

在这里,如果我们先删除记录,然后将使用ROLLBACK命令取回删除的数据。

DELETE FROM STUDENT
WHERE percent=65%;

This will give an output:

这将给出输出:

IDNAMEPhone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
ID 名称 电话号码。 百分
12 Sanyam Gupta 5652156415 79%
43 Divyam Singh 1522141252 85%
76 迪亚·辛哈(Diya Sinha) 4788471154 77%
88 Prabhjeet Singh 9875545566 92%

Now if we use ROLLBACK command, we will get the following:

现在,如果我们使用ROLLBACK命令,我们将获得以下信息:

ROLLBACK;

IDNAMEPhone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
ID 名称 电话号码。 百分
12 Sanyam Gupta 5652156415 79%
43 Divyam Singh 1522141252 85%
76 迪亚·辛哈(Diya Sinha) 4788471154 77%
88 Prabhjeet Singh 9875545566 92%
70 Preena Rajora 8700997912 65%

3)SAVEPOINT命令 (3) The SAVEPOINT Command)

A SAVEPOINT is a point in exchange when you can roll the exchange back in a specific way without moving back the whole exchange.

当您可以以特定方式回滚交换而不回退整个交换时, SAVEPOINT是交换点。

The sentence structure for a SAVEPOINT order is as demonstrated as follows.

SAVEPOINT顺序的句子结构如下所示。

SAVEPOINT SAVEPOINT_NAME;

This order serves just in the formation of a SAVEPOINT among all the value-based explanations. The ROLLBACK order is utilized to fix a gathering of exchanges.

在所有基于值的说明中,此顺序仅用于形成SAVEPOINTROLLBACK订单用于固定交易所的集合。

The sentence structure for moving back to a SAVEPOINT is as demonstrated as follows.

返回到SAVEPOINT的句子结构如下所示。

ROLLBACK TO SAVEPOINT_NAME;

4)SET TRANSACTION命令 (4) The SET TRANSACTION Command)

The SET TRANSACTION order can be utilized to start a database exchange. This order is utilized to determine attributes for the exchange that follows. For instance, you can indicate an exchange to be perused just or perused compose.

SET TRANSACTION顺序可用于启动数据库交换。 该顺序用于确定随后交换的属性。 例如,您可以指示要仔细阅读的交换或仔细阅读的撰写。

The sentence structure for a SET TRANSACTION order is as per the following.

SET TRANSACTION顺序的句子结构如下。

SET TRANSACTION [ READ WRITE | READ ONLY ];


翻译自: https://www.includehelp.com/sql/sql-transactions.aspx

sql事务转账的sql语句

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值