简体   繁体   English

划界交易是什么意思?

[英]What is meant by demarcate transactions?

What is meant by demarcate transactions ? 划界交易是什么意思? When we talk about distributed transactions ? 当我们谈论分布式交易时? Can someone please give me an example so far I only know that it use some code of pseudo code EOT BOT but I have no idea what these are ? 到目前为止,有人可以举一个例子吗,我只知道它使用了伪代码EOT BOT的一些代码,但我不知道这些是什么? Why we need demarcate transactions ? 为什么我们需要划分交易?

In pseudo-code: 用伪代码:

BEGIN TRANSACTION

# modify data here
# possibly taking multiple seconds, minutes, or hours
# during which other users are concurrently modifying 
# data in the system, including the same data records 
# this transaction is modifying

END TRANSACTION

The BEGIN TRANSACTION and END TRANSACTION commands demarcate the transaction. BEGIN TRANSACTIONEND TRANSACTION命令划分事务。 They define what operations are "the transaction." 他们定义什么操作是“交易”。 Namely, the operations that occur between them. 即,它们之间发生的操作。 The END TRANSACTION in real code is usually going to be a COMMIT TRANSACTION or ROLLBACK TRANSACTION type of statement. 实际代码中的END TRANSACTION通常将是COMMIT TRANSACTIONROLLBACK TRANSACTION类型的语句。

You need to demarcate transactions because they might not be a single statement. 您需要对事务进行划分,因为它们可能不是单个语句。 So you need a way to group multiple statements together, then treat them as a single logical operation. 因此,您需要一种将多个语句组合在一起,然后将它们视为单个逻辑操作的方法。 For example: 例如:

BEGIN TRANSACTION
UPDATE accounts SET balance = balance + 100000 WHERE acct_id = 10231212
DELETE FROM deposits WHERE deposit_id = 32984727922121
COMMIT TRANSACTION

If you add a deposit to an account but don't delete it from the list of incoming deposits, that's a bad, bad, bad error for which the recipient will thank you but the bank will not. 如果您将存款添加到帐户中,但不将其从接收到的存款列表中删除,那将是一个严重,严重, 错误的错误,收款人会感谢您,但银行不会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM