Solved

SQL statment for Killing Sessions

Posted on 2004-03-28
6
1,628 Views
Last Modified: 2010-05-18
Hi!

I need a sql statement which will kill all inactive sessions.
Is it possible to schedule running of this statement every day at 1:00 AM?

TNX
0
Comment
Question by:Premanidhi
6 Comments
 
LVL 8

Expert Comment

by:baonguyen1
ID: 10702077
You can try this:

SQL>alter system kill session 'sid,serial#'

where the sid and serial# are from v$session view

Please note that as soon as you run a query and get the results back
in sqlplus, you will see  "inactive" seesions andmost sessions are mostly inactive.

A good way is to set an IDLE time in the PROFILES .  That will kill sessions that have been IDLE for "x" minutes.  Just killing inactive sessions would *not* be a good idea.

Hope this helps

0
 

Author Comment

by:Premanidhi
ID: 10702501
baonguyen1 Could You please explain me how to set IDLE time in the PROFILES?
 
0
 
LVL 8

Accepted Solution

by:
baonguyen1 earned 145 total points
ID: 10702774
You can do:

1. create a profile:

SQL>CREATE PROFILE <profile_name> LIMIT
IDLE_TIME <time in minute>;

For example:

SQL>CREATE PROFILE resourec_limit LIMIT
IDLE_TIME 60;

IDLE_TIME is the number of minutes a session can be connected to the db without being actively used.

Now grant profile to a user:

SQL>ALTER USER <USER>  PROFILE <PROFILE_NAME>;

For example:

SQL>ALTER USER ABC  PROFILE resourec_limit;

Hope this helps
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Expert Comment

by:boriskalavsky
ID: 10707085
The process will be sniped on IDLE time and then cleaned up by PMON (some times it does not work).
0
 

Expert Comment

by:idai
ID: 10730397


but AFAIK you have to set init.ora parameter RESOURCE_LIMIT=True
0
 
LVL 2

Expert Comment

by:vanmeerendonk
ID: 10732493
You could also use the last_call_et from v$session
sysdate - last_call_et/86400 is the last datatime the session "did"something.
We kill everybody that has done nothing for a day
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now