问题描述
ACID 和数据库事务有什么关系?
What is the relationship between ACID and database transaction?
ACID 是给数据库事务还是同一个东西?
Does ACID give database transaction or is it the same thing?
有人可以启发这个话题.
Could someone enlighten this topic.
推荐答案
ACID 是一个集合修改数据库时要应用的属性.
ACID is a set of properties that you would like to apply when modifying a database.
- 原子性
- 一致性
- 隔离
- 耐用性
事务是一组相关的更改,用于实现某些 ACID 属性.事务是实现 ACID 属性的工具.
A transaction is a set of related changes which is used to achieve some of the ACID properties. Transactions are tools to achieve the ACID properties.
原子性意味着你可以保证一个事务的所有发生,或者都不发生;您可以将复杂的操作作为一个单独的单元进行,可以全部执行,也可以不执行,并且崩溃、断电、错误或其他任何事情都不会让您处于只发生了一些相关更改的状态.
Atomicity means that you can guarantee that all of a transaction happens, or none of it does; you can do complex operations as one single unit, all or nothing, and a crash, power failure, error, or anything else won't allow you to be in a state in which only some of the related changes have happened.
一致性意味着您保证您的数据将是一致的;您对相关数据的任何限制都不会被违反.
Consistency means that you guarantee that your data will be consistent; none of the constraints you have on related data will ever be violated.
隔离意味着一个事务不能从另一个尚未完成的事务中读取数据.如果两个事务并发执行,每个事务看到的世界就好像它们在顺序执行一样,如果一个事务需要读取另一个事务写入的数据,则必须等待另一个事务完成.
Isolation means that one transaction cannot read data from another transaction that is not yet completed. If two transactions are executing concurrently, each one will see the world as if they were executing sequentially, and if one needs to read data that is written by another, it will have to wait until the other is finished.
持久性是指一旦交易完成,保证所有的变化都被记录到一个持久的介质(如硬盘)上,交易完成的事实也同样被记录.
Durability means that once a transaction is complete, it is guaranteed that all of the changes have been recorded to a durable medium (such as a hard disk), and the fact that the transaction has been completed is likewise recorded.
所以,事务是保证这些属性的一种机制;它们是一种将相关操作组合在一起的方式,以便作为一个整体,一组操作可以是原子的,产生一致的结果,与其他操作隔离,并被持久记录.
So, transactions are a mechanism for guaranteeing these properties; they are a way of grouping related actions together such that as a whole, a group of operations can be atomic, produce consistent results, be isolated from other operations, and be durably recorded.
这篇关于ACID 和数据库事务如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!