日期:2014-05-16  浏览次数:20454 次

oracle概念_并发和一致
Introduction to Data Concurrency and Consistency
?Data concurrency, which ensures that users can access data at the same time
?Data consistency, which ensures that each user sees a consistent view of the data, including visible changes made by the user's own transactions and committed transactions of other users




Multiversion Read Consistency

oracle的特性
?Read-consistent queries
没有脏读问题
?Nonblocking queries

Statement-Level Read Consistency
Transaction-Level Read Consistency
In this case, each statement in a transaction sees data from the same point in time, which is the time at which the transaction began.
可以重复读,避免了幻读。

undo data,SCN,保持数据多版本.
The database uses a mechanism called an SCN to guarantee the order of transactions.






数据库隔离性

oracle只支持read committed (默认),serializable isolation和read-only mode。

Read Committed Isolation Level
every query executed by a transaction sees only data committed before the query—not the transaction—began.

In a read committed transaction, a conflicting write occurs when the transaction attempts to change a row updated by an uncommitted concurrent transaction, sometimes called a blocking transaction. The read committed transaction waits for the blocking transaction to end and release its row lock. The options are as follows:

?If the blocking transaction rolls back, then the waiting transaction proceeds to change the previously locked row as if the other transaction never existed.
?If the blocking transaction commits and releases its locks, then the waiting transaction proceeds with its intended update to the newly changed row.



Serializable Isolation Level
a transaction sees only changes committed at the time the transaction—not the query—began and changes made by the transaction itself.

Read-Only Isolation Level
is similar to the serializable isolation level, but read-only transactions do not permit data to be modified in the transaction unless the user is SYS.



Lock

exclusive locks and share locks
rules
?A row is locked only when modified by a writer.
?A writer of a row blocks a concurrent writer of the same row.
?A reader never blocks a writer. select ... for update lock the row.
?A writer never blocks a reader.

lock conversion
lock escalation

deadlock
statement-level rollback

DML Locks
DDL Locks
System Locks