查看 Oracle 正在执行的 sql 语句以及发起的用户
SELECT b.sid oracleID,
b.username 用户名,
b.serial#,
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_value
查询当前用户正在执行的SQL
select a.sid,
a.serial#,
a.paddr,
a.machine,
nvl(a.sql_id, a.prev_sql_id) sql_id,
b.sql_text,
b.sql_fulltext,
b.executions,
b.first_load_time,
b.last_load_time,
b.last_active_time,
b.disk_reads,
b.direct_writes,
b.buffer_gets
from v$session a, v$sql b
where a.username = sys_context('USERENV', 'CURRENT_USER')
and a.status = 'ACTIVE'
and nvl(a.sql_id, a.prev_sql_id) = b.sql_id;
查询当前被锁的表
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#;
解除锁命令
alter system kill session 'sid,serial#'