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) |