Duran's technical life
踏踏实实学技术,认认真真做研究。

@title [笔记]事务处理

#1 Transaction Propagation Behavior
Required:Excute within a current tx, create a new one if none exists.
Supports: Excute within a current tx, execute without a tx if none exsits.
Mandatory: Excute within a current tx, throw an exception if none exists.
Requires New: Create a new tx and excute within the tx, suspend the current tx if one exists.
Not Supported: Excute without a tx, suspend the current tx if none exsits.
Never: Excute without a tx, throw an exception if a tx exsits.

#2 Transaction Isolation Level[1]
#2.1 Concurrent Problem
Dirty Reads: 脏读(脏数据指已更新,还没提交的数据)。事务T1读取到事务T2中的脏数据。

Unrepeatable Reads: 不可重复读。事务T1检索到某行后,事务T2更新并提交了该行,若事务T2再次检索该行,则会看到不一样的结果。

Phantom Reads: 虚读。事务T1检索到符合某条件的行集后,事务T2插入并提交了满足该条件的新行,若事务T2再次按该条件检索,则会看到以前不存在的行“Phantom”。

#2.2 Isolation Level
+---------------+-------+------------------+-----------+
|Isolation Level|Phantom|Unrepeatable Reads|Dirty Reads|
+---------------+-------+------------------+-----------+
|Read Uncommited|   Y   |         Y        |     Y     |
+---------------+-------+------------------+-----------+
|Read Commited  |   Y   |         Y        |     N     |
+---------------+-------+------------------+-----------+
|Repeatable Read|   Y   |         N        |     N     |
+---------------+-------+------------------+-----------+
|Serializable   |   N   |         N        |     N     |
+---------------+-------+------------------+-----------+

#3 Timeout

#4 ReadOnly Transaction
只读事务保证了多条查询SQL的在事务级别的读一致性。JDBC和数据库会对只读事务做一些优化。

[1] C.J.Date, An Introduction to Database Systems 7th.

posted on 2005-09-09 13:09 Duran's technical life 阅读(668) 评论(1)  编辑  收藏 所属分类: 技术积累
Comments

只有注册用户登录后才能发表评论。


网站导航: