1).
select lock_info.owner || '.' || lock_info.obj_name as "已鎖物件名稱", --物件名稱(已經被鎖住)
lock_info.subobj_name as "已鎖子物件名稱", -- 子物件名稱(已經被鎖住)
sess_info.machine as "機器名稱", -- 機器名稱
lock_info.session_id as "會話id", -- 會話session_id
sess_info.serial# as "會話serial#", -- 會話serial#
sess_info.spid as "os系統的spid", -- os系統的spid
(select instance_name from v$instance) "例項名sid", --例項名sid
lock_info.ora_username as "oracle使用者", -- oracle系統使用者名稱
lock_info.os_username as "os使用者", -- 作業系統使用者名稱
lock_info.process as "程序編號", -- 程序編號
lock_info.obj_id as "物件id", -- 物件id
lock_info.obj_type as "物件型別", -- 物件型別
sess_info.logon_time as "登入時間", -- 登入時間
sess_info.program as "程式名稱", -- 程式名稱
sess_info.status as "會話狀態", -- 會話狀態
sess_info.lockwait as "等待鎖", -- 等待鎖
sess_info.action as "動作", -- 動作
sess_info.client_info as "客戶資訊" -- 客戶資訊
from (select obj.owner as owner,
obj.object_name as obj_name,
obj.subobject_name as subobj_name,
obj.object_id as obj_id,
obj.object_type as obj_type,
lock_obj.session_id as session_id,
lock_obj.oracle_username as ora_username,
lock_obj.os_user_name as os_username,
lock_obj.process as process
from (select *
from all_objects
where object_id in (select object_id from v$locked_object)) obj,
v$locked_object lock_obj
where obj.object_id = lock_obj.object_id) lock_info,
(select sid,
serial#,
lockwait,
status,
(select spid from v$process where addr = a.paddr) spid,
program,
action,
client_info,
logon_time,
machine
from v$session a) sess_info
where lock_info.session_id = sess_info.sid
order by lock_info.session_id;
2).select sql_text
from v$sqltext
where address in (select sql_address from v$session where sid = &sid)
order by piece;
3).alter system kill session '會話id,會話serial#';
4).kill -9 os系統的spid
oracle查詢鎖表並解鎖
一些oracle中的程序被殺掉後,狀態被置為 killed 但是鎖定的資源很長時間不釋放,有時實在沒辦法,只好重啟資料庫。現在提供一種方法解決這種問題,那就是在oracle中殺不掉的,在os一級再殺。1.下面的語句用來查詢哪些物件被鎖 select object name,machine,s.sid...
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...
Oracle 鎖表 解鎖
以下幾個為相關表 select from v lock select from v sqlarea select from v session select from v process select from v locked object select from all objects sele...