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.
declare
ora_user varchar2(30) default 'HRMS'; --Oracle Username to kill all sessions for
begin
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;
end;
/
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
exit.
declare
ora_user varchar2(30) default 'HRMS'; --Oracle Username to kill all sessions for
begin
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;
end;
/
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
exit.
No comments:
Post a Comment