Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1126068
  • 博文数量: 276
  • 博客积分: 10077
  • 博客等级: 上将
  • 技术积分: 2513
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-24 20:31
文章分类

全部博文(276)

文章存档

2020年(1)

2015年(5)

2012年(2)

2011年(6)

2010年(7)

2009年(224)

2008年(31)

我的朋友

分类: Oracle

2008-11-30 23:17:53

--library cache pin & library cache lock
library cache pin:query P1RAW  of v$session_wait which hash value of object
--X$KGLOB--[K]ernel [G]eneric [L]ibrary Cache Manager [OB]ject
--KGLNAHSH: Hash Value of the object
select ADDR,KGLHDADR,KGLHDPAR,KGLNAOWN,KGLNAOBJ,KGLNAHSH,KGLHDOBJ
from X$KGLOB
where KGLHDADR ='&hashvalue'
--X$KGLPN--[K]ernel [G]eneric [L]ibrary Cache Manager object [P]i[N]s
--获得持有等待对象的session信息
select a.sid,a.username,a.program,b.addr,b.KGLPNADR,b.KGLPNUSE,b.KGLPNSES,b.KGLPNHDL,
b.kGLPNLCK, b.KGLPNMOD, b.KGLPNREQ
from v$session a,x$kglpn b
where a.saddr=b.kglpnuse and b.kglpnhdl = '&hashvalue' and b.KGLPNMOD<>0
====================================================
1.获得Library Cache Pin等待的对象
SELECT addr, kglhdadr, kglhdpar, kglnaown, kglnaobj, kglnahsh, kglhdobj
  FROM x$kglob
 WHERE kglhdadr IN
       (SELECT p1raw FROM v$session_wait WHERE event LIKE 'library%')
2.获得持有等待对象的session信息
SELECT a.SID,
       a.username,
       a.program,
       b.addr,
       b.kglpnadr,
       b.kglpnuse,
       b.kglpnses,
       b.kglpnhdl,
       b.kglpnlck,
       b.kglpnmod,
       b.kglpnreq
  FROM v$session a, x$kglpn b
 WHERE a.saddr = b.kglpnuse
   AND b.kglpnmod <> 0
   AND b.kglpnhdl IN
       (SELECT p1raw FROM v$session_wait WHERE event LIKE 'library%')
3.获得持有对象用户执行的代码
SELECT sql_text
  FROM v$sqlarea
 WHERE (v$sqlarea.address, v$sqlarea.hash_value) IN
       (SELECT sql_address, sql_hash_value
          FROM v$session
         WHERE SID IN (SELECT SID
                         FROM v$session a, x$kglpn b
                        WHERE a.saddr = b.kglpnuse
                          AND b.kglpnmod <> 0
                          AND b.kglpnhdl IN
                              (SELECT p1raw
                                 FROM v$session_wait
                                WHERE event LIKE 'library%')))
阅读(986) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~