Oracle自治事务的介绍(Autonomous Transactions)PRAGMA AUTONOMOUS_TRANSACTION

Autonomous transactions allow you to leave the context of the calling transaction, perform an independant transaction, and return to the calling transaction without affecting it's state. The autonomous transaction has no link to the calling transaction, so only commited data can be shared by both transactions.
自治事务允许你离开调用的事务上下文,执行一个独立的事务,然后返回调用的事务而不会影响到调用事务的状态。自治事务和调用事务不同,只有提交的事务才会在事务见共享。


The following types of PL/SQL blocks can be defined as autonomous transactions:
以下的PL/SQL代码块可以定义为自治事务。

    * Stored procedures and functions. 存储过程和函数
    * Local procedures and functions defined in a PL/SQL declaration block. 定义在声明块里的本地存储过程和函数
    * Packaged procedures and functions. 打包的存储过程和函数
    * Type methods. 类型方法
    * Top-level anonymous blocks. 顶层的匿名块

The easiest way to understand autonomous transactions is to see them in action. To do this, we create a test table and populate it with two rows. Notice that the data is not commited.
最简单的理解自治事务的方法是查看他们的行为。我们创建一个测试表格,然后放入2行数据,注意数据没有提交。


    CREATE TABLE at_test (
      id NUMBER NOT NULL,
      description VARCHAR2(50) NOT NULL
    );

    INSERT INTO at_test (id, description) VALUES (1, 'Description for 1');
    INSERT INTO at_test (id, descr

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值