删除oracle用户报ORA-01940: cannot drop a user that is current

Posted 枫&vce

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了删除oracle用户报ORA-01940: cannot drop a user that is current相关的知识,希望对你有一定的参考价值。

删除数据库用户的时候经常会遇到这样的错误;

ORA-01940: cannot drop a user that is currently connected

原因是有程序在连接我们需要删除的用户,我们删除用户之前一定要先把连接断掉;

1、查找帐号下哪些连接在运行:

SELECT SID,SERIAL# FROM V$SESSION WHERE USERNAME=‘USERNAME‘;


注意:此处需要大写

SQL> SELECT SID,SERIAL# FROM V$SESSION WHERE USERNAME=‘SSTEST‘;


SID SERIAL#
---------- ----------
137 41813
335 25993
464 58747
500 9153
531 50402
629 9264
631 11237
664 36180


8 rows selected.

2、删除用户进程;

SQL>ALTER SYSTEM KILL SESSION ‘137,41813‘;

System altered.

SQL>ALTER SYSTEM KILL SESSION ‘33525993;

System altered.

3、重新查看用户连接,并确认无连接在使用

SELECT SID,SERIAL# FROM V$SESSION WHERE USERNAME=‘SSCRM‘;

4、删除用户

drop user sstest cascade;

 

以上是关于删除oracle用户报ORA-01940: cannot drop a user that is current的主要内容,如果未能解决你的问题,请参考以下文章

ORA-01940: cannot drop a user that is currently

ORA-01940: cannot drop a user that is currently connected

ORA-01940 无法删除当前已连接的用户

ORA-01940: cannot drop a user that is currently connected 问题解析

Oracle增删改查--之删

ORACLE 下查看用户session 及 kill 用户session