我使用的是oracle11g数据库。我有一个名为
phonenumbers_tbl
的表,我在该表上执行了 DROP
命令。但它返回错误resource busy and acquire with NOWAIT specified or timeout expired
。之后,我使用命令 alter session set ddl_lock_timeout = 600
更改会话,并再次尝试删除表格。但这个错误仍然存在
尝试先执行此操作,并检查是否有来自
other session
或 your session
的人对该表加了锁。如果 you
对该表加了锁,请尝试执行 commit/rollback
。如果 someone else
将一把锁,询问 him/her
或者你是否有权限 kill his session
。然后删除表。
select session_id "sid",SERIAL# "Serial",
substr(object_name,1,20) "Object",
substr(os_user_name,1,10) "Terminal",
substr(oracle_username,1,10) "Locker",
nvl(lockwait,'active') "Wait",
decode(locked_mode,
2, 'row share',
3, 'row exclusive',
4, 'share',
5, 'share row exclusive',
6, 'exclusive', 'unknown') "Lockmode",
OBJECT_TYPE "Type"
FROM
SYS.V_$LOCKED_OBJECT A,
SYS.ALL_OBJECTS B,
SYS.V_$SESSION c
WHERE
A.OBJECT_ID = B.OBJECT_ID AND
C.SID = A.SESSION_ID
ORDER BY 1 ASC, 5 Desc
是的!最后我得到了一个解决方案,将表
phonenumber_tbl
移动到另一个表空间system
并删除表。
首先获取表锁会话,然后杀死会话
选择a.sid,a.serial#,a.用户名,c.os_user_name,a.terminal,
b.object_id,substr(b.object_name,1,40) object_name
来自 v$session a、dba_objects b、v$locked_object c
其中 a.sid = c.session_id
并且 b.object_id = c.object_id;
ALTER SYSTEM KILL SESSION 'sid,serial#' ;
您可以执行以下代码:
select c.owner, c.object_name, c.object_type,b.sid, b.serial#, b.status
from gv$locked_object a , gv$session b, dba_objects c
where b.sid = a.session_id
and a.object_id = c.object_id;