来,复习一哈Oracle事务的ACID特性



All Oracle transactions comply with the basic properties of a database transaction, known as ACID properties.
ACID is an acronym for the following:

1. Atomicity
All tasks of a transaction are performed or none of them are. There are no partial transactions.
For example, if a transaction starts updating 100 rows, but the system fails after 20 updates, then the database rolls back the changes to these 20 rows.

2. Consistency
The transaction takes the database from one consistent state to another consistent state.
For example, in a banking transaction that debits a savings account and credits a checking account, a failure must not cause the database to credit only
one account, which would lead to inconsistent data.

3. Isolation
The effect of a transaction is not visible to other transactions until the transaction is committed.
For example, one user updating the hr.employees table does not see the uncommitted changes to employees made concurrently by another user.
Thus, it appears to users as if transactions are executing serially.

4. Durability
Changes made by committed transactions are permanent.
After a transaction completes, the database ensures through its recovery mechanisms that changes from the transaction are not lost.

翻译为:

所有的oracle事务都遵循数据库基本的事务特性,就是所谓的ACID特性。
ACID是以下四个事务特性的缩写:

1. 原子性
一个事务的所有工作要么都(成功)执行,要么都不执行。不会发生只执行一部分的情况。
比如说,一个事务开始更新100行记录,但是在更新了20行之后(因为某种原因)失败了,那么此时数据库会回滚(撤销)对那20条记录的修改。

2. 一致性
事务将数据库从一个一致性状态带入另一个一致性状态。
比如说,在一个银行事务(在描述关系数据库事务的特性时,基本上都是用银行事务来作为描述对象的)中,需要从存储账户扣除款项,然后在支付账户中增加款项。
如果在这个中转的过程发生了失败,那么绝对不能让数据库只执行其中一个账户的操作,因为这样会导致数据处于不一致的状态(这样的话,银行的账目上,借贷就不平衡了)。

3. 隔离性
这个特性是说,直到事务结束时(commit/rollback),其他事务(或者会话)对此事务所操作的数据都不可见(但并不是说其他会话的读取会被阻塞)。
比如说,一个用户正在修改hr.employees表,但是没有提交,那么其他用户在这个修改没有提交之前是看不到这个修改的。

4. 永久性
被提交的更改会永久地保存到数据库中(并不是说以后就不可以修改)。
事务提交之后,数据库必须通过“恢复机制”来确保事务更改的数据不会丢失。

以上内容来自Oracle联机文档《Database Concepts Manual 11g.pdf》p209。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值