ORA-01940: cannot drop a user that is currently connected
Error :-
SQL> drop user TAPROD cascade;
drop user TAPROD cascade
*
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected
SQL>
drop user TAPROD cascade
*
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected
SQL>
Solution :-
Make sure the user is logged out, then re-execute the command.
If you are permitted to kill the session of that user then find out the connected user sid and serial# by
SQL> select s.sid, s.serial#, s.status, p.spid
from v$session s, v$process p
where s.username = ‘User_Name’
and p.addr (+) = s.paddr
SID SERIAL# STATUS SPID
———- ———- ——– ————————
221 45 ACTIVE 25372
235 3 ACTIVE 25374
from v$session s, v$process p
where s.username = ‘User_Name’
and p.addr (+) = s.paddr
SID SERIAL# STATUS SPID
———- ———- ——– ————————
221 45 ACTIVE 25372
235 3 ACTIVE 25374
NOTE: Before killing session you may wish to lock the account for further connection attempts. This is extremely necessary to drop users who automatically establish session like to drop an application user or to drop a user who performs batch jobs.
SQL> Alter user username account lock;
Now kill the connected session.
SQL> alter system kill session ‘221,45’;
System altered
SQL> alter system kill session ‘235,3’;
System altered
And then drop the user.
SQL> drop user username cascade;
User dropped
Now kill the connected session.
SQL> alter system kill session ‘221,45’;
System altered
SQL> alter system kill session ‘235,3’;
System altered
And then drop the user.
SQL> drop user username cascade;
User dropped
Comments
Post a Comment