oracle的drop user用法
(2012-01-31 13:14:40)
标签:
杂谈 |
分类: Oracle学习 |
- SQL> drop
user
test cascade;
- drop user test
cascade
- *
- ERROR at line 1:
- ORA-01940: cannot drop
a user that is
currently connected
-
-
- SQL> select
username,sid,serial# from
v$session;
-
-
USERNAME
SID SERIAL# - ------------------------------ ----------
----------
-
SYSMAN
118 43411 -
test
122 483 -
test
123 391 -
SYS
125 626 -
DBSNMP
129 48 -
SYSMAN
130 247 -
DBSNMP
136 113 -
SYSMAN
138 15 -
SYSMAN
141 3 -
143 50435 -
152 3 -
-
-
USERNAME
SID SERIAL# - ------------------------------ ----------
----------
-
153 3 -
SYSMAN
158 15 -
160 1 -
161 1 -
162 1 -
163 1 -
164 1 -
165 1 -
166 1 -
167 1 -
168 1 -
-
USERNAME
SID SERIAL# - ------------------------------ ----------
----------
-
169 1 -
170 1 -
- SQL>alter system kill
session '122,483';
-
- SQL> drop
user
test cascade;
-
(**)如果在drop 后还提示ORA-01940:无法删除当前已链接的用户,说明还有连接的session,可以通过查看session的状态来确定该session是否被kill 了,用如下语句查看:
-------------------------------------
select saddr,sid,serial#,paddr,username,status from v$session where username is not null
结果如下(以我的库为例):
saddr
sid serial# paddr username status --------------------------------------------------------------------------------------------------------
564A1E28
513 22974 569638F4 NETBNEW ACTIVE
564A30DC514 18183 569688CC NETBNEW INACTIVE
564A5644516 21573 56963340 NETBNEW INACTIVE
564B6ED0531 9 56962D8C NETBNEW INACTIVE
564B8184532 4562