ORA-01940: cannot drop a user that is currently connecte
程序员文章站
2024-01-27 17:56:28
...
ORA-01940: cannot drop a user that is currently connecte
当我们删除某个用户时,如果要删除的用户当前正连接Oracle数据库,则会报错:
SQL> conn /as sysdba
Connected.
SQL> drop user fc cascade;
drop user fc cascade
*
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected.
通过v$session视图查出要删除的用户当前session信息,然后kill掉该用户session连接:
SQL> select sid,serial# from v$session where username='FC';
SID SERIAL#
---------- ----------
150 9019
SQL> alter system kill session '150,9019';
System altered.
再执行drop user操作便可成功:
SQL> drop user fc cascade;
User dropped.