ORA-01940: cannot drop a user that is currently connected
Posted Beng Dou
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORA-01940: cannot drop a user that is currently connected相关的知识,希望对你有一定的参考价值。
操作环境
SuSE11+Oracle11gR2
问题现象
删除oracle数据库用户失败,提示ORA-01940: cannot drop a user that is currently connected错误
问题分析
NA
问题解决
1、SQL>SELECT SID,SERIAL# FROM V$SESSION WHERE USERNAME=‘USERNAE‘;
2、SQL>ALTER SYSTEM DISCONNECT SESSION ‘SID,SERIAL#‘ IMMEDIATE;
知识延伸
oracle杀掉会话进程有3种方式
1、ALTER SYSTEM KILL SESSION。不是真正干掉会话,只是标记会话状态为killed,等待pmon进程清除。这种方式不适合用于删除oracle用户的脚本,有可能到时死循环。可以使用ALTER SYSTEM KILL SESSION ‘sid,serial#‘ IMMEDIATE;
2、ALTER SYSTEM DISCONNECT SESSION,可以直接从操作系统干掉进程。有如下2种形式。
SQL > ALTER SYSTEM DISCONNECT SESSION ‘sid,serial#‘ POST_TRANSACTION; #等待事务完成断开会话
SQL>ALTER SYSTEM DISCONNECT SESSION ‘sid,serial#‘ IMMEDIATE; # 立即中断会话
3、KILL -9 SPID。根据SQL查找到相关进程,kill掉。
以上是关于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
(转)oracle中用户删除不了,ORA-01940提示 “无法删除当前已连接用户”
Cannot drop a database link after changing the global_name ORA-02024 (文档 ID 382994.1)