--查詢Oracle正在執(zhí)行的sql語(yǔ)句及執(zhí)行該語(yǔ)句的用戶
- SELECT b.sid oracleID,
- b.username 登錄Oracle用戶名,
- b.serial#,
- spid 操作系統(tǒng)ID,
- paddr,
- sql_text 正在執(zhí)行的SQL,
- b.machine 計(jì)算機(jī)名
- FROM v$process a, v$session b, v$sqlarea c
- WHERE a.addr = b.paddr
- AND b.sql_hash_value = c.hash_value
--查看正在執(zhí)行sql的發(fā)起者的發(fā)放程序
- SELECT OSUSER 電腦登錄身份,
- PROGRAM 發(fā)起請(qǐng)求的程序,
- USERNAME 登錄系統(tǒng)的用戶名,
- SCHEMANAME,
- B.Cpu_Time 花費(fèi)cpu的時(shí)間,
- STATUS,
- B.SQL_TEXT 執(zhí)行的sql
- FROM V$SESSION A
- LEFT JOIN V$SQL B ON A.SQL_ADDRESS = B.ADDRESS
- AND A.SQL_HASH_VALUE = B.HASH_VALUE
- ORDER BY b.cpu_time DESC
--查出oracle當(dāng)前的被鎖對(duì)象
- SELECT l.session_id sid,
- s.serial#,
- l.locked_mode 鎖模式,
- l.oracle_username 登錄用戶,
- l.os_user_name 登錄機(jī)器用戶名,
- s.machine 機(jī)器名,
- s.terminal 終端用戶名,
- o.object_name 被鎖對(duì)象名,
- s.logon_time 登錄數(shù)據(jù)庫(kù)時(shí)間
- FROM v$locked_object l, all_objects o, v$session s
- WHERE l.object_id = o.object_id
- AND l.session_id = s.sid
- ORDER BY sid, s.serial#;
--kill掉當(dāng)前的鎖對(duì)象可以為
alter system kill session 'sid, s.serial#‘;
|