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

Posted sharpest

tags:

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

转自:

https://www.linuxidc.com/Linux/2012-12/76448.htm

 

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

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 ;

 

以上是关于ORA-01940: cannot drop a user that is currently connected 问题解析的主要内容,如果未能解决你的问题,请参考以下文章

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

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

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

(转)oracle中用户删除不了,ORA-01940提示 “无法删除当前已连接用户”

Cannot drop a database link after changing the global_name ORA-02024 (文档 ID 382994.1)

day10_小计