在執行drop user的時候,提示報錯信息:ORA-01940: cannot drop a user that is currently connected
SQL> drop user ecity ; ERROR at line 1: ORA-01940: cannot drop a user that is currently connected
造成這個問題的原因是很明顯的,有用戶在連接,不允許drop掉該user。
解決方案:
首先查詢一下數據中有沒有用戶在使用
select username,sid,serial#,paddr from v$session where username='ECITY';
USERNAME SID SERIAL# PADDR ------------------------------ ---------- ------------------------------------------------- ECITY 634 7 00000000C028D198
SQL> select PROGRAM from v$process where addr='00000000C028D198';
PROGRAM ---------------------------------------------------------------------------------------------------------- Oracle@oradb01 (DW00)
其次殺掉系統中的這個進程
SQL> alter system kill session '634,7'; System altered.
然后執行刪除操作,即可完成
SQL> select saddr,sid,serial#,paddr,username,status from v$session where username is not null; SQL> drop user ecity CASCADE; User dropped.
問題解決,記得KILL進程前,先看看是啥進程,哪台機連過來的,能否KILL等等。避免殺掉其他進程
