资源描述:
《oracle常用的检查锁和的脚本》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、oracle常用的检查锁和的脚本把Oracle中常用的检查锁和闩的脚本总结一些。1.用于检查系统中锁的简单脚本selects.username,s.sid,1.type,1.idl,1.id2,1.1mode,1.request,p.spidPIDfromv$lock1,v$sessions,v$processpwheres.sid=1.sidandp.addr=s.paddrands.usernameisnotnullorderbyidl,s.sid,request:2.显示数据库锁的信息setpagesize60setlinesize132selects.usernameus
2、ername,a.sidsid,a.ownera.objectobject,s.lockwait,t.sqltextsqlfromv$sqItextt,v$sessions,v$accessawheret.address=s.sqladdressandt.hashvalue=s.sqlhashvalueands.sid=a.sidanda.owner!='SYS'andupper(substr(a・object,1,2))!='V$';1.产生在数据库中持有的锁的报表selectb.sid,c.username,c.osuser,c.terminal,decode(b.id2,0
3、,a.object_name,'Trans~,to_char(b・idl))object_name,b.type,decode(b.lmode,0,1,2,3,4,-Waiting-',NulT,RowShare,,RowExcT,Share,,5,'ShaRowExc',6,'Exclusive','Other')"LockMode",decode(b.request,0,…,1,'Null',2,'RowShare',3,'RowExcT,4,'Share,,5,'ShaRowExc,,6,'Exclusive','Other')"ReqMode"fromdba_object
4、sa,v$lockb,v$sessioncwherea.object_id(+)二b.idlandb.sid二c.sidandc.usernameisnotnullorderbyb・sid,b.id2;2.产生等待锁的用户的报告columnusernameformatal5columnsidformat9990headingsidcolumntypeformata4columnlmodeformat990heading'IIELD'columnrequestformat990heading'REQ'columnidlformat9999990columnid2format9999
5、990breakonidlskip1dupspooltfslckwt.1stselectsn.username,m.sid,m.type,decode(m.lmode,0,'None',1,'Null',2,'RowShare,,3,'RowExcl.',4,'Share,,5,'S/RowExcl.6,'Exclusive',lmode,1trim(to_cha.r(lmode,,990’)))lmode,decode(m.request,0,'None',1,^NulT,2,'RowShare",3,,RowExcl.',4,'Share,,5,'S/RowExcl,',6,
6、'Exclusive',request,ltrim(to_char(m・request,990')))request,m.idl,m.id2fromv$sessionsn,v$lockmwhere(sn・sid二m.sidandm.request!二0)or(sn・sid二m.sidandm.request二0andlmode二4and(idl,id2)in(selects.idl,s.id2fromv$lockswhererequest!二0ands.idl二m・idlands.id2二m.id2))orderbyidl,id2,m.request;spooloffclearb
7、reaks1.显示持有锁的会话的信息setlinesize132pagesize66breakonKillonusernameonterminalcolumnKillheadingJKillString,fromatal3columnresheading'ResourceType'format999columnidlformat9999990columnid2format9999990columnlmodeheading'LockIIeld,formata20columnrequ