【发布时间】:2017-12-22 02:14:35
【问题描述】:
在将重用表上的现有列更改为“非空”时,我希望避免出现以下错误消息或任何其他错误消息:
SQL Error: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
00054. 00000 - "resource busy and acquire with NOWAIT specified or timeout expired"
*Cause: Interested resource is busy.
*Action: Retry if necessary or increase timeout.
我的 Oracle 版本是:Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production。我尝试了如下排他锁,但我仍然得到错误。我通过在其他会话中执行一些 DML 来模拟一个使用量很大的表。
会话 1
create table iei1731 (
col1 varchar2(1 char),
col2 number(1,0)
);
insert into iei1731 (col1, col2) values ('1', 0);
commit;
update iei1731 set col1 = col1 where col1 = '1';
第 2 节
lock table iei1731 in exclusive mode;
会话 1
rollback; -- now session 2 gets the exclusive lock on the table
update iei1731 set col1 = col1 where col1 = '1';
第 2 节
alter table iei1731 modify col2 not null; -- here I get the ORA-00054
会话 1(清理)
rollback;
drop table iei1731;
所以我的问题是,是否有可能将这个重用表上的列设置为不为空而没有任何错误消息?
【问题讨论】:
-
也许这更适合dba.stackexchange.com ?