当前位置:Gxlcms > mysql > ORA-01940:cannotdropauserthatiscurrentlyconnecte

ORA-01940:cannotdropauserthatiscurrentlyconnecte

时间:2021-07-01 10:21:17 帮助过:20人阅读

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.

linux

人气教程排行