I've been tagged [This link opens in a new window]

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='<user>'

After getting your results from here, run the below:

ALTER system KILL SESSION '<sid,serial#>'

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

If you find, after ALTERing a table you are getting errors with queries using bind variables, run this procedure and it should fix it.
  • Del.icio.us [This link opens in a new window]
  • Digg [This link opens in a new window]
  • Technorati [This link opens in a new window]
  • Reddit [This link opens in a new window]
  • Stumble Upon [This link opens in a new window]
  • Furl [This link opens in a new window]