2012-10-13 11gR2 concepts page 161 - 192


JDBC Drivers

我觉得一项技术最难的不是如何使用,而是何时使用,怎么去使用更好。

Advantages of Triggers -- 触发器的优势
You can use triggers to:
-- Automatically generate derived column values
-- Prevent invalid transactions
-- Provide auditing and event logging
-- Record information about table access

Excessive use of triggers can result in complex interdependencies that can be difficult
to maintain in a large application. For example, when a trigger is invoked, a SQL
statement within its trigger action potentially can fire other triggers, resulting in
cascading triggers that can produce unintended effects.

触发器虽然有很多的优势,但也不可滥用。

Read Consistency and Undo Segments -- 通过UNDO 回滚段实现读一致性
To manage the multiversion read consistency model, the database must create a
read-consistent set of data when a table is simultaneously queried and updated. Oracle
Database achieves this goal through undo data.
Whenever a user modifies data, Oracle Database creates undo entries, which it writes
to undo segments ("Undo Segments" on page 12-24). The undo segments contain the
old values of data that have been changed by uncommitted or recently committed
transactions. Thus, multiple versions of the same data, all at different points in time,
can exist in the database. The database can use snapshots of data at different points in
time to provide read-consistent views of the data and enable nonblocking queries.


Read consistency is guaranteed in single-instance and Oracle Real Application
Clusters (Oracle RAC) environments. Oracle RAC uses a cache-to-cache block transfer
mechanism known as Cache Fusion to transfer read-consistent images of data blocks
from one database instance to another.

Orace RAC通过CACHE FUSION技术实现脏块在实例间的传递。

Read Consistency and Transaction Tables -- 实际上事物槽(ITL)越多,可以承受的并发数越多。
The database uses a transaction table, also
called an interested transaction list (ITL), to determine if a transaction was
uncommitted when the database began modifying the block. The block header of
every segment block contains a transaction table.
Entries in the transaction table describe which transactions have rows locked and
which rows in the block contain committed and uncommitted changes. The
transaction table points to the undo segment, which provides information about the
timing of changes made to the database.


Locking Mechanisms
ANSI/ISO Transaction Isolation Levels
These isolation levels are defined in terms of phenomena that must be prevented
between concurrently executing transactions. The preventable phenomena are:
-- Dirty reads -- 脏读
A transaction reads data that has been written by another transaction that has not
been committed yet.
-- Nonrepeatable (fuzzy) reads -- 重复读
A transaction rereads data it has previously read and finds that another committed
transaction has modified or deleted the data. For example, a user queries a row
and then later queries the same row, only to discover that the data has changed.
-- Phantom reads -- 随机读
A transaction reruns a query returning a set of rows that satisfies a search
condition and finds that another committed transaction has inserted additional
rows that satisfy the condition.
For example, a transaction queries the number of employees. Five minutes later it
performs the same query, but now the number has increased by one because
another user inserted a record for a new hire. More data satisfies the query criteria
than before, but unlike in a fuzzy read the previously read data is unchanged.

Oracle Database offers the read committed (default) and serializable isolation levels.
Also, the database offers a read-only mode.


Lock Modes
Oracle Database uses two modes of locking in a multiuser database:
-- Exclusive lock mode -- 互斥锁
This mode prevents the associated resource from being shared. A transaction
obtains an exclusive lock when it modifies data. The first transaction to lock a
resource exclusively is the only transaction that can alter the resource until the
exclusive lock is released.
-- Share lock mode -- 共享锁
This mode allows the associated resource to be shared, depending on the
operations involved. Multiple users reading data can share the data, holding share
locks to prevent concurrent access by a writer who needs an exclusive lock.
Several transactions can acquire share locks on the same resource.

Assume that a transaction uses a SELECT ... FOR UPDATE statement to select a
single table row. The transaction acquires an exclusive row lock and a row share table
lock. The row lock allows other sessions to modify any rows other than the locked row,
while the table lock prevents sessions from altering the structure of the table. Thus, the
database permits as many statements as possible to execute.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值