首页 > 应用开发 > IT综合 > Row Locks (TX) (342)

Row Locks (TX) (342)

原创 IT综合 作者:tsinglee 时间:2007-12-10 11:46:35 0 删除 编辑

Row-level locks are primarily used to prevent two transactions from modifying the
same row. When a transaction needs to modify a row, a row lock is acquired.

There is no limit to the number of row locks held by a statement or transaction, and
Oracle does not escalate locks from the row level to a coarser granularity. Row locking
provides the finest grain locking possible and so provides the best possible
concurrency and throughput.

The combination of multiversion concurrency control and row-level locking means
that users contend for data only when accessing the same rows, specifically:
■ Readers of data do not wait for writers of the same data rows.
■ Writers of data do not wait for readers of the same data rows unless SELECT ...
FOR UPDATE is used, which specifically requests a lock for the reader.
■ Writers only wait for other writers if they attempt to update the same rows at the
same time.

A transaction acquires an exclusive row lock for each individual row modified by one
of the following statements: INSERT, UPDATE, DELETE, and SELECT with the FOR
UPDATE clause.

A modified row is always locked exclusively so that other transactions cannot modify
the row until the transaction holding the lock is committed or rolled back. However, if
the transaction dies due to instance failure, block-level recovery makes a row available
before the entire transaction is recovered. Row locks are always acquired automatically
by Oracle as a result of the statements listed previously.

If a transaction obtains a row lock for a row, the transaction also acquires a table lock
for the corresponding table. The table lock prevents conflicting DDL operations that
would override data changes in a current transaction.

1. 当一个事务需要修改一行记录时, 就获得了行级锁 . 该锁主要用来阻止两个事务同时修改相同的行
2. 一个事务或一个SQL语句能获得的行级锁数目没有限制
3. 在执行下列语句时,事务需要获得被修改的每一数据行的排他行锁: INSERT,UPDATE,DELETE,


来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

上一篇: DML Locks (341)
下一篇: Table Locks (TM) (343)
请登录后发表评论 登录
  • 博文量
  • 访问量