3:39 pm
0
2056
views

How to kill a user's session in Oracle

This has happened a few times to me, so it's worth jotting down how to fix it.

When you want to drop a user/schema in Oracle, sometimes you get an error explaining that the user you are trying to drop still has a session and you are therefore prevented from dropping that user.

Well this is remedied quite easily by running the below to kill that particular user's session:

SELECT sid,serial# FROM v$session
WHERE username=''

After getting your results from here, run the below:

ALTER system KILL SESSION ''

This will kill all the sessions associated to this user, effectively allowing you to know drop the user.