select a.program, b.spid, c.sql_text,c.SQL_ID
from v$session a, v$process b, v$sqlarea c
where a.paddr = b.addr
and a.sql_hash_value = c.hash_value
and a.username is not null;html
因爲sql_text列沒有顯示完整
的sql語句.因此找到sql_id:686nqabc8sgs2再查詢v$sql
select a.* from v$sql a where a.SQL_ID='686nqabc8sgs2'
能夠查看完整的sql文本內容
--查詢Oracle正在執行的sql語句及執行該語句的用戶
SELECT b.sid oracleID,
b.username 登陸Oracle用戶名,
b.serial#,
spid 操做系統ID,
paddr,
sql_text 正在執行的SQL,
b.machine 計算機名
FROM v$process a, v$session b, v$sqlarea c
WHERE a.addr = b.paddr
AND b.sql_hash_value = c.hash_valuesql
--查看正在執行sql的發起者的發放程序數據庫
SELECT OSUSER 電腦登陸身份,
PROGRAM 發起請求的程序,
USERNAME 登陸系統的用戶名,
SCHEMANAME,
B.Cpu_Time 花費cpu的時間,
STATUS,
B.SQL_TEXT 執行的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 DESCsession
--查出oracle當前的被鎖對象oracle
SELECT l.session_id sid,
s.serial#,
l.locked_mode 鎖模式,
l.oracle_username 登陸用戶,
l.os_user_name 登陸機器用戶名,
s.machine 機器名,
s.terminal 終端用戶名,
o.object_name 被鎖對象名,
s.logon_time 登陸數據庫時間
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#;