DDL锁

    Every create,alter andso on statement is really executed as shown in this pseudo-code:

Begin
	Commit;
	DDL-STATEMENT
	Commit;
Exception
	When others then rollback;
END;

有三种DDL锁

       排他DDL锁 theseprevent other sessions from gaining a DDL lock or TM (DML) lock themselves. Thismeans that you may query a table during a DDL operation, but you may not modifyit in any way.

 

      共享DDL锁:this protectthe structure of the reference object against modification by other sessions,but allow modification to the data.

 

      Breakable parse locks:thisallow an object, such as a query plan cached in the shared pool, to registerits reliance on some other object. If you perform DDL against that object,oraclewill review the list of objects that have registered their dependence andinvalidate them.hence these locks are “breakable” –they do not prevent the DDLfrom occurring.


You can install this and other locking views by runing the catblock.sql crpit found in thedirectory[ORACLE_HOME]/rdbms/admin.

SQL> desc dba_ddl_locks
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 SESSION_ID                                         NUMBER
 OWNER                                              VARCHAR2(30)
 NAME                                               VARCHAR2(30)
 TYPE                                               VARCHAR2(40)
 MODE_HELD                                          VARCHAR2(9)
 MODE_REQUESTED                                    VARCHAR2(9)

在这个视图中,owner列不是LOCK的拥有者,而是被锁住的object的属主。

 To see a breakable parse lock in action. Letus first create and run a stored procedure P:


SQL> create or replace procedure p is begin null;end;
  2  /

Procedure created.

SQL> exec p;

PL/SQL procedure successfully completed.

SQL> select * from dba_ddl_locks where name = 'P';

SESSION_ID OWNER                          NAME
---------- ------------------------------ ------------------------------
TYPE                                     MODE_HELD MODE_REQU
---------------------------------------- --------- ---------
       149 OPS                            P
Table/Procedure/Type                     Null      None


重新编译下存储过程P,重新查询一下

SQL> alter procedure p compile;

Procedure altered.

SQL> select * from dba_ddl_locks where name = 'P';

no rows selected

oracle  parse  lock  has  been  broken.





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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值