Oracle 11g ddl_lock_timeout

来源:互联网 发布:淘宝闲鱼拍卖是正品吗 编辑:程序博客网 时间:2024/06/03 06:42

    在Oracle 11g之前,当一个表上还有事务,此时不能对表进行DDL操作,否则会马上报错。在11g里引进了ddl_lock_timeout这个参数,可以等上一段时间后还没有获得锁,才会报错。我个人认为这个新特性用处不大,知道就行了。

session1:

SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> drop table test purge;
SQL> create table test(id number(10));
SQL> insert into test values(1);
已创建 1 行。

session2:
SQL> show parameter ddl_lock_timeout;
NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------

ddl_lock_timeout                     integer     0

SQL> set timing on
SQL> drop table test;
drop table test
           *
第 1 行出现错误:
ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效
已用时间:  00: 00: 00.01

SQL> alter session set ddl_lock_timeout = 10;
SQL> drop table test;
drop table test
           *
第 1 行出现错误:
ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效
已用时间:  00: 00: 10.01

0 0