在重用表上将现有列更改为"not null“时,我希望避免下列错误消息或任何其他错误消息:
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数据库12c企业版发行版12.1.0.2.0-64位生产。我尝试了一个排他性锁,如下所示,但我仍然得到了错误。我通过在其他会话中做一些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;那么,我的问题是,是否有可能将这个使用频繁的表上的列设置为null,而没有任何错误消息?
发布于 2017-07-18 02:08:53
使用超时让会话等待锁:
--Wait up to 10 minutes to acquire the lock.
alter session set DDL_LOCK_TIMEOUT=600;
alter table iei1731 modify col2 not null;发布于 2017-07-17 13:58:41
如果它是完全锁定-不-锁将必须首先释放。
进行非空更改也是元数据更改,因此,如果大量访问该对象,您将创建一个可能的“行缓存”锁,而该行缓存锁将使其他人在队列中等待对象访问,直到您的null成功。这可能导致在繁忙的生产环境中等待的雪球。最好在停机时间或较少繁忙的时间对元数据进行更改。
https://stackoverflow.com/questions/45145974
复制相似问题