Pages

Monday, September 19, 2011

Procedure to kill database session

应用用户用如下procedure kill session:
SQL> connect

Enter password:

Connected.

假设有TEST用户,
SQL> select sid,serial# from v$session where username='TEST';

SID SERIAL#

---------- ----------

401 209

SQL> execute kill_session(401,209);


PL/SQL procedure successfully completed.


SQL>

SQL> select sid,serial#,status from v$session where username='TEST';



SID SERIAL# STATUS

---------- ---------- --------

401 209 KILLED



SQL> /
no rows selected

如果提示没有数据,说明需要Kill的session不存在没有找到

SQL> execute kill_session(463,81);

BEGIN kill_session(463,81); END;
*

ERROR at line 1:

ORA-01403: no data found

ORA-06512: at "SYS.KILL_SESSION", line 7

ORA-06512: at line 1

No comments: