2.下面的语句用来杀死一个进程:alter system kill session '966,13432'; (其中966,13432分别是上面查询出的sid,serial#)
【注】以上两步,可以通过Oracle的管理控制台来执行。
3.如果利用上面的命令杀死一个进程后,进程状态被置为"killed",但是锁定的资源很长时间没有被释放,那么可以在os一级再杀死相应的进程(线程),首先执行下面的语句获得进程(线程)号:
select spid, osuser, s.programwhere s.paddr=p.addr and s.sid=966 (966是上面的sid)
抓取执行计划
--方案1
--查看sql执行计划
SQL> col plan_table_output format a200
SQL>
SQL> EXPLAIN PLAN FOR SELECT * FROM dual;
SQL> select * from table(dbms_xplan.display);
--方案2
--以下是查看正在执行的sql
--查看刚刚执行的sid
select sid from v$mystat where rownum<2;
--根据sid查询sql_id
SELECT sql_id FROM v$session WHERE SID=761
--跟踪sql阻塞
SELECT username,event,p1,p2,p3 ,sql_id FROM v$session WHERE sql_id='c75qmuhpdxmhb';
--利用游标,抓取执行计划
SELECT * FROM table(dbms_xplan.display_cursor('c75qmuhpdxmhb',0));
SELECT username,event,p1,p2,p3,B.SQL_TEXT,A.SQL_ID FROM v$session a, v$sql b WHERE a.sql_id=b.sql_id
AND a.username='UNICOMCS_V3'
SELECT username,event,p1,p2,p3,B.SQL_TEXT,A.SQL_ID FROM v$session a, v$sql b WHERE a.sql_id=b.sql_id
AND a.username='UNICOMCS_V3'
查看等待
select (sysdate-a.logon_time)*24*60 minutes,
a.username,
a.BLOCKING_INSTANCE,
a.BLOCKING_SESSION,
a.program,
a.machine,
a.osuser,
a.status,
a.sid,
a.serial#,
a.event,
a.p1,
a.p2,
a.p3,
a.sql_id,
a.sql_child_number,
b.sql_text
from v$session a, v$sql b
where
a.sql_address = b.address
and a.sql_hash_value = b.hash_value
and a.sql_child_number=b.child_number
and a.username like '%MOBILE_V1%'
order by 1 desc;
SELECT program,event ,username FROM v$session WHERE SID=766