SQL> create user will identified by 123;
create user will identified by 123
SQL> grant connect,resource to will;
Grant succeeded
SQL> commit;
Commit complete
//删除失败
SQL> drop user will cascade;
drop user will cascade
ORA-01940: 无法删除当前连接的用户
<pre name="code" class="sql">//检查权限
SQL> show user;
User is "SYS"
//检查系统的会话,并杀掉对应进程
SQL> select username, sid, serial# from v$session;
USERNAME SID SERIAL#
------------------------------ ---------- ----------
1 1
2 1
3 1
4 1
SYSMAN 5 76
6 6
SCOTT 8 2754
PUBLIC 10 2447
SYSMAN 11 3
WILL 14 1093
DBSNMP 63 39
64 1
65 1
66 1
DBSNMP 67 110
68 4376
SYSMAN 69 783
DBSNMP 71 22
SYS 72 6429
SYS 74 252
USERNAME SID SERIAL#
------------------------------ ---------- ----------
125 1
126 1
127 1
128 1
SYSMAN 130 16
131 5276
132 15
SYSMAN 134 85
WILL 135 1391
137 1605
187 1
188 1
189 1
190 1
192 5
195 1
196 1
SYSMAN 197 6
SYSTEM 198 2806
SYSMAN 200 2396
40 rows selected
SQL> alter system kill session'14,1093';
System altered
SQL> alter system kill session'135,1391';
System altered
//继续删除用户
SQL> drop user will cascade;
User dropped