ITPub博客

首页 > 数据库 > Oracle > 11g_DDL_Lock_Timeout

11g_DDL_Lock_Timeout

原创 Oracle 作者:zhyuh 时间:2009-09-27 10:17:36 0 删除 编辑

DDL_LOCK_TIMEOUT是11g新引进的参数,主要特征如下:

Parameter type => Integer
Default value => 0
Modifiable => ALTER SESSION
Range of values => 0 to 1,000,000 (in seconds)

[@more@]

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.


在系统繁忙的时候,合理设置这个参数有些作用。比如在以前版本中,经常碰到下面的情况:

**************
* 10g
**************

--session 1
SQL> create table table1(col1 number);

Table created

SQL> insert into table1 values(1);

1 row inserted

--sessionn 2
SQL> alter table table1 add col2 number;

alter table table1 add col2 number

ORA-00054: resource busy and acquire with NOWAIT specified


**************
* 11g
**************

--session 1
SQL> create table table1(col1 number);

Table created.

SQL> insert into table1 values(1);

1 row created.

--session 2

SQL> alter session set DDL_LOCK_TIMEOUT =10;

Session altered.

SQL> alter table table1 add col2 number;

Table altered.

Elapsed: 00:00:00.04

SQL> alter table table1 drop column col2;
alter table table1 drop column col2
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired


Elapsed: 00:00:10.06

在11g中,add column操作可以马上完成,而不会出现ORA-00054错误,但是对于drop column操作,则会等待10秒钟(DDL_LOCK_TIMEOUT =10)。如果10秒钟内session 1还没有提交/回退更改,session 2会因为timeout报ORA-00054错误,如果10秒钟内session 1释放锁,则session 2的drop操作可以自己完成。比如session 2重新执行drop column操作,而session 1大概3秒钟后释放锁,则session 2顺利完成。


SQL> alter table table1 drop column col2;

Table altered.

Elapsed: 00:00:03.58

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

上一篇: 11g_Password
请登录后发表评论 登录
全部评论
  • 博文量
    233
  • 访问量
    2061863