Chinaunix首页 | 论坛 | 博客
  • 博客访问: 928425
  • 博文数量: 358
  • 博客积分: 8185
  • 博客等级: 中将
  • 技术积分: 3751
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:27
个人简介

The views and opinions expressed all for my own,only for study and test, not reflect the views of Any Company and its affiliates.

文章分类

全部博文(358)

文章存档

2012年(8)

2011年(18)

2010年(50)

2009年(218)

2008年(64)

我的朋友

分类: Oracle

2009-09-04 17:47:43

 
■Shared and Exclusive Locks
排他锁:可以定义在行级,表级;只能由一个Session持有
共享锁:只能定义在表级;能由多个Session持有,防止其它会话对同一表加表级排他锁;
        DDL操作需要对表加表级排他锁,所以可以防止DDL操作。
■DML and DDL Locks
・All DML statements require at least two locks:
an exclusive lock on each row affected,and a shared lock on the table containing the row.
The exclusive lock prevents another session from interfering with the row, and the shared lock prevents another session from changing the table definition with a DDL statement.
・To execute DDL commands requires an exclusive lock on the object concerned.
■Manual Locking
・lock table t1 in exclusive mode;
release the table lock by issuing a COMMIT or ROLLBACK
・SELECT...FOR UPDATE NOWAIT
  SELECT...FOR UPDATE WAIT
The SELECT...FOR UPDATE command will select rows and lock them in exclusive mode.
■Lock Contention
・"Deadlocks" are not the DBA’s problem; they are caused by bad program design and are resolved automatically by the database itself.
Information regarding deadlocks is written out to the alert log, with full details in a trace file;
・SET TRANSACTION READ ONLY
This will guarantee (without imposing any locks) that the session does not see any DML on any tables, committed or not, until it
terminates the read-only transaction with a COMMIT or ROLLBACK.

■Resolving Lock Contention
・ALTER SYSTEM KILL SESSION 'id,serial#'
When a session is terminated forcibly, any locks it holds will be released as its activetransaction is rolled back.
阅读(355) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~