时间:2021-07-01 10:21:17 帮助过:49人阅读
-------------------查看当前有哪些用户正在使用数据 SELECT osuser, a.username,cpu_time/executions/1000000||'s', sql_fulltext,machine from v$session a, v$sqlarea b where a.sql_address =b.address order by cpu_time/executions desc; ------------
-------------------查看当前有哪些用户正在使用数据
SELECT osuser, a.username,cpu_time/executions/1000000||'s', sql_fulltext,machine
from v$session a, v$sqlarea b
where a.sql_address =b.address order by cpu_time/executions desc;
--------------------查询是什么SQL引起了锁表的原因
select l.session_id sid,
s.serial#,
l.locked_mode,
l.oracle_username,
s.user#,
l.os_user_name,
s.machine,
s.terminal,
a.sql_text,
a.action
from v$sqlarea a, v$session s, v$locked_object l
where l.session_id = s.sid
and s.prev_sql_addr = a.address
order by sid, s.serial#;
--------------------查看被锁对象和解锁方法
(1)被锁对象
select a.SID, a.SERIAL#, c.object_name, b.oracle_username,b.os_user_name
from
v$session a,
v$locked_object b,
v$process p,
all_objects c
where
a.process=b.process and
a.paddr=p.addr and
b.object_id= c.object_id;