Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL statment for Killing Sessions

Posted on 2004-03-28
6
Medium Priority
?
1,647 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 580 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

604 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