Join this Blog for direct reference of any post into your inbox. To join just click on "Join this Site" under "Follower" then Login with your Email.*** DECLARATION: I Maintain this Blog for Helping Myself While at Work and Welcome any body Needing Help!!!.*** CAUTION: Using any of the script from this Blog may contain at Own Risk. These scripts May or May not have been Tested.***

Sunday, 17 February 2013

How to Kill Idle Session

Consider a situation when DBA having some maintenance task. He has already passed the message to all the database user to stop using the database and he finds some of the users is still using the database and he is not able to communicate with that particular user (may be he is not available of chair) then DBA choose to kill that session. For this purpose either you can use Toad or run the below batch file.
   ora_user varchar2(30) default 'HRMS'; --Oracle Username to kill all sessions for
   execute immediate 'alter user '||ora_user||' account lock';
   for crs in (select sid,serial# from v$session where username = ora_user) loop
      execute immediate 'alter system kill session '''||crs.sid||','||crs.serial#||'''';
   end loop;
How to Kill idle Session of particular Schema
Contents: kill_idle_sessions.bat
sqlplus orafin/**** @d:\kill_idle_sessions.sql

Contents: kill_idle_sessions.sql
connect / as sysdba
exec kill_idle_sessions


Post a Comment