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)
Properties Description
Atomicity It 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.
Consistency It guarantees that the database appropriately changes states upon an effectively dedicated exchange.
Isolation It empowers exchanges to work autonomously and straightforward to one another.
Durability It 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命令⼀起使⽤ ,例如-INSERT , UPDATE和DELETE 。 在创建表或删除表时,我们⽆法使⽤这些命令。
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订单是基于价值的订单,⽤于节省由于交换⽽导致的对数据库的更改。 ⾃上⼀个COMMIT或ROLLBACK指令以来, COMMIT指令将所有交换保留到数据库中。
The language structure for the COMMIT order is as per the following.
COMMIT命令的语⾔结构如下。
COMMIT;
Example:
例:
We will consider the following STUDENT table:
我们将考虑以下学⽣表:
ID NAME Phone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
ID名称电话号码。百分
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76迪亚·⾟哈(Diya Sinha)478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
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:
我们将得到以下结果:
ID NAME Phone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
ID名称电话号码。百分
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76迪亚·⾟哈(Diya Sinha)478847115477%
88Prabhjeet Singh987554556692%
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顺序是基于值的顺序,⽤于修复到⽬前为⽌尚未保存到数据库的交换。 ⾃从给出最后⼀个COMMIT或ROLLBACK命令以来,必须利⽤此命令来固定交换。
The punctuation for a ROLLBACK order is as per the following.
ROLLBACK顺序的标点如下。
ROLLBACK;
Consider the following data table:
考虑以下数据表:
ID NAME Phone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
ID名称电话号码。百分
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76迪亚·⾟哈(Diya Sinha)478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
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:
这将给出输出:
ID NAME Phone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
ID名称电话号码。百分12Sanyam Gupta565215641579%43Divyam Singh152214125285%76迪亚·
⾟哈(Diya Sinha)478847115477%88Prabhjeet Singh987554556692%Now if we use ROLLBACK command, we will get the following:
现在,如果我们使⽤ROLLBACK命令,我们将获得以下信息:
ROLLBACK;
ID NAME Phone No.Percent
12Sanyam Gupta565215641579%
43Divyam Singh152214125285%
76Diya Sinha478847115477%
88Prabhjeet Singh987554556692%
70Preena Rajora870099791265%
ID名称电话号码。百分12Sanyam Gupta565215641579%43Divyam Singh152214125285%76迪亚·⾟哈(Diya Sinha)478847115477%88Prabhjeet Singh987554556692%70Preena Rajora8700997912
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是交换点。
每天学点sql经典句子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.
在所有基于值的说明中,此顺序仅⽤于形成SAVEPOINT 。 ROLLBACK订单⽤于固定交易所的集合。
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 ];
翻译⾃:
sql事务转账的sql语句
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论