什么是数据库事务? [英] What is a database transaction?

查看:145
本文介绍了什么是数据库事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以提供一个真正简单的(但不是简单的)一个事务的应用于计算(即使从维基百科复制)吗?

Can someone provide a really simple (but not simpler than possible) explanation of a transaction as applied to computing (even if copied from Wikipedia)?

推荐答案

交易是一个工作单元,您希望将其视为整体。

A transaction is a unit of work that you want to treat as "a whole". It has to either happen in full, or not at all.

一个典型的例子是将钱从一个银行帐户转移到另一个银行帐户。为此,您必须先从源帐户提取金额,然后将其存入目标帐户。操作必须成功。如果你停止一半,钱将会丢失,这是非常糟糕。

A classical example is transferring money from one bank account to another. To do that you have to first withdraw the amount from the source account, and then deposit it to the destination account. The operation has to succeed in full. If you stop halfway, the money will be lost, and that is Very Bad.

在现代数据库事务也做了一些其他事情,如确保你不能访问另一个人写了半条数据。但基本的想法是一样的 - 交易有确保,无论发生什么,您的工作的数据将处于一个合理的状态。他们保证不会出现从一个帐户中提取款项,而不会存入另一个帐户的情况。

In modern databases transactions also do some other things - like ensure that you can't access data that another person has written halfway. But the basic idea is the same - transactions are there to ensure, that no matter what happens, the data you work with will be in a sensible state. They guarantee that there will NOT be a situation where money is withdrawn from one account, but not deposited to another.

这篇关于什么是数据库事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆