Press "Enter" to skip to content

ORA-01940 无法删除当前已连接的用户之解决方案

在执行drop user的时候,提示报错信息:ORA-01940: cannot drop a user that is currently connected

SQL> drop user ecity ;
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected

造成这个问题的原因是很明显的,有用户在连接,不允许drop掉该user。

解决方案:

首先查询一下数据中有没有用户在使用

select username,sid,serial#,paddr from v$session where username='ECITY';

USERNAME                                    SID    SERIAL# PADDR
------------------------------ ---------- -------------------------------------------------
ECITY                                       634        7   00000000C028D198

SQL> select PROGRAM from v$process where addr='00000000C028D198';

PROGRAM
----------------------------------------------------------------------------------------------------------
Oracle@oradb01 (DW00)

其次杀掉系统中的这个进程

SQL> alter system kill session '634,7';
System altered.

然后执行删除操作,即可完成

SQL> select saddr,sid,serial#,paddr,username,status from v$session where username is not null;
SQL> drop user ecity CASCADE;
User dropped.

注:本文转自https://www.cnblogs.com/lwlxqlccc/p/8694696.html

Be First to Comment

发表评论

电子邮件地址不会被公开。 必填项已用*标注