Oracle 变量之 DDL_LOCK_TIMEOUT

DDL_LOCK_TIMEOUT

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

DDL_LOCK_TIMEOUTspecifies a time limit for how long DDL statements will wait in a DML lock queue. The default value of zero indicates a status ofNOWAIT. 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.

该参数是oralce 11g中才有的;

实验:

--session 1

SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 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> show parameter ddl
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
ddl_lock_timeout integer 0
enable_ddl_logging boolean FALSE

--session 2

SQL> insert into t_1 values('b');
1 row created.

--session 3

SQL> alter table t_1 modify(a varchar2(50));
alter table t_1 modify(a varchar2(50))
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
该错误是执行之后没有等待直接出现;

--session 1

SQL> alter system set ddl_lock_timeout=60;
System altered.

SQL> show parameter ddl
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
ddl_lock_timeout integer 60
enable_ddl_logging boolean FALSE

--session 2

SQL> insert into t_1 values('a');
1 row created.

--session 3

SQL> alter table t_1 modify (a varchar2(30));
alter table t_1 modify (a varchar2(30))
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

该错误是在等待了60秒之后才出现;

--session 3

SQL> alter table t_1 add c number;

则会一直等待下去,直到请求的锁资源被释放(该变量不起作用);

在网上有些文章说,如果是添加列回立即提交,不敢苟同;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值