11g新特性:DDL锁超时

在11g中,oracle提供了一个新的可动态调整的参数ddl_lock_timeout,该参数允许存在未提交的事务的表上,执行DDL操作,如果事务在ddl_lock_timeout允许的时间内提交,则DDL操作将会成功,否则就会报ORA-00054错误,如果对该表执行ADD COLUMN操作,则会直接提交表上发生的未提交的事务,所以用11g时,有些东西还是要注意的,当然也不排除这是11g的一个bug哦。。。

[@more@]

11g以前的版本测试如下:
SESSION 1:
16:18:34 SQL> delete from tmp_lg_log where rownum < 2;
1 row deleted.

SESSION 2:
16:21:10 SQL> alter table tmp_lg_log add rn number;
alter table tmp_lg_log add rn number
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified

11g中测试DDL锁超时:
SESSION 1:
SQL> create table tmp_lg_log (id number,name varchar2(32),rn1 number, rn2 number);
Table created.
SQL> insert into tmp_lg_log values(1,'abc',1,2);
1 row created.

SESSION 2:
SQL> show parameter lock
NAME_COL_PLUS_SHOW_PARAM TYPE VALUE_COL_PLUS_SHOW_PARAM
------------------------- ----------- ---------------------
ddl_lock_timeout integer 0
--修改锁超时时间
SQL> alter system set ddl_lock_timeout=60 scope=both;
System altered.
--执行ddl(drop column)的操作,事务未在60s内提交,所以报timeout错误
SQL> alter table tmp_lg_log drop column rn2;
alter table tmp_lg_log drop column rn2
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
--执行ddl(add column)的操作,DDL则立即成功
SQL> alter table tmp_lg_log add rn4 number;
Table altered.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16648/viewspace-941923/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16648/viewspace-941923/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值