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