After killing session by using ALTER SYSTEM KILL SESSION
, I tried to drop the user, but it says the user is connected.
So when I again killed the session and tried to drop the user, I observed that each time I kill a session, immediately another session is getting created.
Example :
I run the query "Drop user cascade" : it says user connected cannot drop
I run the query:
SELECT 'ALTER SYSTEM KILL SESSION '''||s.sid||','|| s.serial#||''';'
FROM v$session s, v$process p
WHERE lower(s.username) = 'username'
AND p.addr(+) = s.paddr and status='INACTIVE';
I get a query to kill sessions, now I kill all the sessions and run the drop user command again, it says user connected.
Checking for sessions again on the user shows a single inactive session which is getting created each time.
Dropping a user for an application that quickly reconnects may require a few steps:
alter user username account lock
alter system kill session ...
select used_urec, gv$transaction.* from gv$transaction
drop user username