Oracle 系统管理

這是當前運行的sql語句

select sid,
v$session.username 用戶名,
last_call_et 持續時間,
status 狀態,
LOCKWAIT 等待鎖,
machine 用戶電腦名,
logon_time 開始登入時間,
sql_text
from v$session, v$process, v$sqlarea
where paddr = addr
and sql_hash_value = hash_value
and status = 'ACTIVE'
and v$session.username is not null
order by last_call_et desc;
------------------------------------------------------------------------------------

根據sid查詢已經執行過的sql

select sql_text from v$sqlarea a,v$session b where a.SQL_ID=b.PREV_SQL_ID and b.SID=&sid;
--------------------------------------------------------------------------------------

根據sid查詢當前執行的sql

select sql_text from v$sqlarea where (hash_value,address)=(select sql_hash_value,sql_address from v$session where sid=&sid);
-----------------------------------------------------------------------------------------

查詢oracle 鎖表情況

select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid

---------------------------------------------------------------------------------------------

殺掉鎖表的語句

如有t表示有lock,下SID和serial# ,⒂的ID替Q下面的738,1429,即可解除LOCK
alter system kill session '1793,25320';

你可能感兴趣的:(oracle)