Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Disconnect connected sessions
Daniel Morgan wrote:
> "Yuri Weinstein (HotMail)" wrote:
>>Can you give me a query example? >> >>The reason I am dropping and recreating the db - testing, I need to test >>some stuff. >> >>thx >> >><snipped>
Yes, below is a query example (to answer the question of the OP). This can be run from a Unix shell script (or a Windows batch file with some naming conventions changed). I have never had a problem with waiting for the session to be killed.
To answer some other questions:
Let's say you want to test an import you are about to send to a customer; it's much more reproducible to start with a freshly-created user in a known state.
2) Why not call each connected user of the schema to be dropped before forcibly disconnecting their sessions? Because it might be 2:30 in the morning and you have a batch job which needs to do an import without human intervention. The users might be programmers who have forgotten to log out during the scheduled down time, or they might not even be human at all, such as JDBC connection pool sessions.
Mark Bole
query example:
set head off
set echo off
set termout off
set verify off
set pagesize 0
set feedback off
set timing off
spool /tmp/kill_sess.sql
select 'alter system disconnect session '''
|| s.sid || ',' || s.serial# || ''' immediate;'
from v$session s
where s.username <in your list of users>
and status <> 'KILLED';
spool off
/
set echo on
set verify on
set feedback on
set termout on
@/tmp/kill_sess
drop user <your schema owner> cascade; Received on Wed Apr 23 2003 - 20:15:19 CDT