声明:本文为转载,如果有侵犯知识版本,请通知本人,本人将即刻停止侵权行为:
http://blog.csdn.net/tianlesoftware/article/details/7412555
Oracle存储过程无法编译,在PL/SQL中编译,总是挂住了,这个原因可能是要编译的对象被会话给锁住了:
1、查看无效对象:
1 SELECT Object_Name, Object_Type, Status 2 FROM All_Objects 3 WHERE Status = 'INVALID' 4 AND Owner = 'SCOTT';
2、查看正在访问无效对象的会话,这里我们需要使用v$access
V$ACCESS displaysinformation about locks that are currently imposed on library cache objects.The locks are imposed to ensure that they are not aged out of the library cachewhile they are required for SQL execution.
1 SELECT * FROM V$ACCESS WHERE OBJECT='CREATE_VIEW_P';
查询出来的结果显示是:会话ID为143的会话当前持有该对象。
3、查询143号的会话的状态
1 SELECT Sid, Serial#, Status, Process FROM V$session WHERE Sid = '143';
4、杀掉进程:
1 alter system kill session '143,397';
5、查询进行的状态:
1 select sid,serial#,status,process from v$session where sid='958';
session的状态在刚刚杀掉的时候为KILLED,但是被标记为killed 的进程由PMON 进程kill,但是这个也是有条件的:
PMON will notdelete the session object itself until the client connected to that sessionnotices that it has been killed.如果session 被标记为killed,并且长时间不能被清楚,MOS上给出的解决方法是在OS级别kill 进程。
6、获取session的spid(系统进程ID)
V$PROCESS中的常用列
ADDR:进程对象地址
PID:oracle进程ID
SPID:操作系统进程ID
V$PROCESS中的连接列
Column View Joined Column(s)
ADDR V$SESSION PADDR
网址:http://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_2022.htm
1 SELECT Spid, Osuser, s.Program 2 FROM V$session s, V$process p 3 WHERE s.Paddr = p.Addr 4 AND s.Sid = 143;
查询系统进行ID,使用系统级别的KILL命令:
可参考:
windows命令:
To kill the session on the Windows operating system, first identify the session, then substitute the relevant SID
and SPID
values into the following command issued from the command line.
1 C:> orakill ORACLE_SID(数据库实例名) spid(v$process表中获取)
成功----