ITPub博客

首页 > 数据库 > Oracle > 11gR1引入的新特性:可等待DDL操作

11gR1引入的新特性:可等待DDL操作

原创 Oracle 作者:warehouse 时间:2013-05-31 11:51:28 0 删除 编辑

简单的记录了一个测试过程。

[@more@]

11gR1之前ddl是不会等待的,如果有不兼容的锁,直接返回错误:ORA-00054: resource busy and acquire with NOWAIT specified,从11gR1开始,返回的错误有一点小小的变化:

ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

错误提示当中多了or timeout expired,这个提示其实就是针对DDL可等待这个新特性的。

11gR1引入了一个参数:

DDL_LOCK_TIMEOUT

PropertyDescription
Parameter typeInteger
Default value0
ModifiableALTER SESSION
Range of values0 to 1,000,000 (in seconds)
BasicNo

DDL_LOCK_TIMEOUT specifies a time limit for how long DDL statements will wait in a DML lock queue. The default value of zero indicates a status of NOWAIT. The maximum value of 1,000,000 seconds will result in the DDL statement waiting forever to acquire a DML lock.

If a lock is not acquired before the timeout period expires, then an error is returned.

下面是一个简单的测试过程:

session 1:

SQL> update t set id=1 where name='a';

1 row updated.

SQL>

session 2:

SQL> show parameter ddl

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
ddl_lock_timeout integer 0
enable_ddl_logging boolean FALSE
SQL> drop table t;
drop table t
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired


SQL> alter session set ddl_lock_timeout=10;

Session altered.

SQL> set time on
11:49:38 SQL>
11:49:44 SQL> drop table t;
drop table t
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired


11:49:55 SQL>
这里我们能感觉到延迟了10秒之后才报错。

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

请登录后发表评论 登录
全部评论

注册时间:2007-12-07

  • 博文量
    717
  • 访问量
    5366307