Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2322457
  • 博文数量: 310
  • 博客积分: 6853
  • 博客等级: 准将
  • 技术积分: 2833
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-04 16:41
文章分类

全部博文(310)

文章存档

2013年(17)

2012年(42)

2011年(76)

2010年(71)

2009年(99)

2007年(2)

2006年(1)

2005年(2)

分类: Oracle

2009-07-16 23:40:55

Lock Description

锁粒度:
DML locks (data locks) DML locks protect data. For example, table locks lock entire
tables, row locks lock selected rows.
DDL locks (dictionary locks) DDL locks protect the structure of schema objects—for
example, the definitions of tables and views.
Internal locks and latches Internal locks and latches protect internal database structures
such as datafiles. Internal locks and latches are entirely
automatic

锁方式:
Locks Obtained By DML Statements

 DML Statement  Row Locks?  Mode of Table Lock
 SELECT ... FROM table    
 INSERT INTO table ...  X  RX
 UPDATE table ...  X  RX
 DELETE FROM table ...  X  RX
 SELECT ... FROM table ... 
FORUPDATE OF ...
 X  RS

锁持续的时间
从语句开始到事务结束。

开发中关注的DML LOCK.

Row Locks (TX)行锁、表锁,(没有索引锁?)
DML operations can acquire data locks at two different levels: for specific rows and for entire tables.


锁的总量:
没有限制。There is no limit to the number of row locks held by a statement or transaction

锁升级
不会锁升级:Oracle does not escalate locks from the row level to a coarser granularity

查询与锁
查询不用行锁,也不用表锁。
读写之间不会互锁或者锁等待。

一条语句的锁数量
获取锁的级别数量。同时会获取两个级别的锁。
If a transaction obtains a row lock for a row, the transaction also acquires a table lock for the corresponding table


Table Locks (TM)表锁

获取表锁的语句
A transaction acquires a table lock when a table is modified in the following DML
statements: INSERT, UPDATE, DELETE, SELECT with the FOR UPDATE clause, and
LOCK TABLE.

表锁的目的:
These DML operations require table locks for two purposes:
to reserve DML access to the table on behalf of a transaction
and to prevent DDL operations that would conflict with the transaction.

不会阻止DML?部分类型会阻止。

表锁的类型
A table lock can be held in any of several modes: row share (RS), row exclusive
(RX), share (S), share row exclusive (SRX), and exclusive (X).

表锁间的关系

阅读(1614) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~