4 Transaction Management
001 |
This chapter defines a transaction and describes how you can manage your
work using transactions. |
本章阐述了事务(transaction)的定义,并讲解如何使用事务来管理数据库操作。 |
002 | This chapter contains the following topics: | 本章包含以下主题: |
003 |
Introduction to Transactions |
4.1 事务简介 |
004 |
A transaction is a logical unit of work that contains one or more
SQL statements. A transaction is an atomic unit. The effects of all the
SQL statements in a transaction can be either all committed
(applied to the database) or all rolled back (undone from the
database). |
事务(transaction)是由一个或多个 SQL 语句组成的逻辑操作单位(logical unit of work)。事务具备原子性(atomic)。一个事务内所有 SQL 语句对数据库产生的影响,或者被全部提交(committed)(作用到数据库中),或者被全部回滚(rolled back)(将对数据库的 修改撤销)。 |
005 |
A transaction begins with the first executable SQL statement. A
transaction ends when it is committed or rolled back, either explicitly
with a COMMIT or
ROLLBACK statement or implicitly when a DDL statement is issued. |
一个事务(transaction)开始于用户提交的第一条可执行的(executable)SQL 语句,结束于之后进行的提交(commit)或回滚(roll back)操作。使用 COMMIT 或 ROLLBACK 语句能够显式地结束事务,而提交一个 DDL 语句可以隐式地结束事务。 |
006 |
To illustrate the concept of a transaction, consider a banking database.
When a bank customer transfers money from a savings account to a
checking account, the transaction can consist of three separate
operations:
|
为了形象地讲解事务的概念,可以以一个银行数据库为例。假设一个银行客户需要将资金从储蓄账户转移到支票帐户,处理此业务的事务应由三个独立的操作构成:
|
007 |
Oracle must allow for two situations. If all three SQL statements can be
performed to maintain the accounts in proper balance, the effects of the
transaction can be applied to the database. However, if a problem such
as insufficient funds, invalid account number, or a hardware failure
prevents one or two of the statements in the transaction from
completing, the entire transaction must be rolled back so that the
balance of all accounts is correct. |
Oracle 需要考虑两种情况。如果三条 SQL 语句全部正常执行,使帐户间的平衡得以保证,那么此事务(transaction)中对数据的修改就可以应用到数据库中。但是如果发生诸如资金不足,账号错误,或硬件故障等问题,导致事务中一 条或两条 SQL 语句不能执行,那么整个事务必须被回滚(roll back)才能保证帐户间的平衡。 |
008 |
Figure 4-1 illustrates the banking transaction example. |
图4-1 展示了银行事务(transaction)的例子。 |
009 |
Figure 4-1 A Banking
Transaction |
图4-1 银行事务 |
010 | ||
011 |
Figure 4-1 shows the SQL statement for the banking transaction example. The statement is divided into four blocks: |
图4-1 显示了一个银行事务(transaction)所包含的 SQL 语句。此事务可以分为以下四步骤: |
012 |
Statement Execution and Transaction Control |
4.1.1 语句执行与事务控制 |
013 |
A SQL statement that runs successfully is different from a committed
transaction. Executing successfully means that a single statement was:
|
一个成功执行的 SQL 语句与一个提交的事务(transaction)是有区别的。一个 SQL 语句成功执行表明此语句:
|
014 |
However, until the transaction that contains the statement is committed,
the transaction can be rolled back, and all of the changes of the
statement can be undone. A statement, rather than a transaction, runs
successfully. |
但是在包含此语句的事务(transaction)被提交(commit)之前,整个事务都可以被回滚(roll back),事务内所有语句对数据库的修改都可以被撤销。尽管发生了回滚,事务内的 SQL 语句却是成功执行的。 |
015 |
Committing means that a user has explicitly or implicitly
requested that the changes in the transaction be made permanent. An
explicit request occurs when the user issues a
COMMIT statement. An implicit request occurs after normal
termination of an application or completion of a data definition
language (DDL) operation. The changes made by the SQL statement(s) of a
transaction become permanent and visible to other users only after that
transaction commits. Queries that are issued after the transaction
commits will see the committed changes. |
提交(commit)意味着用户显式地或隐式地要求将事务(transaction)中对数据的修改永久地记录到数据库中。当用户执行 COMMIT 语句时即为显式的提交操作,当数据库应用程序正常结束或一个数据定义语句(data definition language,DDL)成功执行后将发生隐式 的提交操作。事务被提交后,事务内 SQL 语句的对数据的修改将被永久地记录到数据库中,其他用户将能够看到这些改变。在事务提交后执行的查询就能看变化后的数据了。 |
016 |
You can name a transaction using the SET
TRANSACTION ... NAME statement before you start the transaction.
This makes it easier to monitor long-running transactions and to resolve
in-doubt distributed transactions. |
用户可以在开始一个事务(transaction)时使用 SET TRANSACTION ... NAME 语句为此事务命名。这有助于用户监控长时间运行的事务,以及处理不可信的分布式事务(in-doubt distributed transaction)。 |
017 |
See Also: |
另见: |
018 |
Statement-Level Rollback |
4.1.2 语句级回滚 |
019 |
If at any time during execution a SQL statement causes an error, all
effects of the statement are rolled back. The effect of the rollback is
as if that statement had never been run. This operation is a
statement-level rollback. |
如果在一个 SQL 语句在执行过程中发生了错误,那么此语句对数据库产生的影响将被回滚(roll back)。回滚后就如同此语句从未执行过。这种操作被称为语句级回滚(statement-level rollback)。 |
020 |
Errors discovered during SQL statement execution cause
statement-level rollbacks. An example of such an error is attempting to
insert a duplicate value in a primary key. Single SQL statements
involved in a deadlock (competition for the same data) can also
cause a statement-level rollback. Errors discovered during SQL statement
parsing, such as a syntax error, have not yet been run, so they
do not cause a statement-level rollback. |
在语句执行(execution)过程中发生的错误将会导致语句级回滚(statement-level rollback),例如向一个表中插入数据造成主键(primary key)值重复即为此类错误。一个造成死锁(deadlock)(访问相同数据而产生的竞争)的 SQL 语句也会导致语句级回滚。而在 SQL 语句解析(parsing)的过程中发现错误(例如语法错误),因为此语句还没有被执行,所以不会产生语句级回滚。 |
021 |
A SQL statement that fails causes the loss only of any work it would
have performed itself. It does not cause the loss of any work that
preceded it in the current transaction. If the statement is a DDL
statement, then the implicit commit that immediately preceded it is not
undone. |
一个 SQL 语句执行失败只会使此语句所做的数据修改无效,而不会导致当前事务(transaction)中此语句之前的语句所做的数据修改失效。如果执行失败的是 DDL 语句,那么在此语句之前隐式执行的提交(commit)操作不会被撤销。 |
022 |
Note: |
提示: |
023 |
See Also: |
另见: |
024 |
Resumable Space Allocation |
4.1.3 可恢复的空间分配问题 |
025 |
Oracle provides a means for suspending, and later resuming, the
execution of large database operations in the event of space allocation
failures. This enables an administrator to take corrective action,
instead of the Oracle database server returning an error to the user.
After the error condition is corrected, the suspended operation
automatically resumes. |
当一个持续时间较长的数据库操作在执行过程中遭遇空间分配失败时,Oracle 可以将此操作暂时挂起(suspend),并在空间分配问题解决后恢复(resume)其执行。当发生空间分配问题时,Oracle 数据库服务器不会立即给执行此操作的用户返回错误提示,而是等待管理员解决此问题。当空间分配问题被纠正后,挂起的操作可以自动地恢复执行。 |
026 |
A statement runs in a resumable mode only when the client explicitly
enables resumable semantics for the session using the
ALTER SESSION statement. |
只有在客户端使用 ALTER SESSION 语句的语法显式地将会话(session)设定为可恢复( resumable)后,SQL 语句才能运行在可恢复模式下(resumable mode)。 |
027 |
Resumable space allocation is suspended when one of the following
conditions occur:
|
当满足以下条件之一时,运行于可恢复的空间分配模式下的语句将被挂起(suspend):
|
028 |
For nonresumable space allocation, these conditions result in errors and
the statement is rolled back. |
在不可恢复的空间分配模式下,以上条件将导致运行错误,并使 SQL 语句回滚(roll back)。 |
029 |
Suspending a statement automatically results in suspending the
transaction. Thus all transactional resources are held through a
statement suspend and resume. |
语句被挂起(suspend)将导致其所在事务(transaction)同时被挂起。事务所使用的所有资源在语句挂起期间都将被保留。 |
030 |
When the error condition disappears (for example, as a result of user
intervention or perhaps sort space released by other queries), the
suspended statement automatically resumes execution. |
当产生错误的条件消除后(例如,管理员进行了处理,或其他查询使用的排序空间(sort space)已经被释放),被挂起(suspend)的语句将自动地恢复(resume)执行。 |
031 |
See Also: |
另见: |
032 |
Overview of Transaction Management |
4.2 事务管理概述 |
033 |
A transaction in Oracle begins when the first executable SQL statement
is encountered. An executable SQL statement is a SQL statement
that generates calls to an instance, including DML and DDL statements. |
在 Oracle 中一个事务(transaction)开始于首个可执行的 SQL 语句(executable SQL statement)。可执行的 SQL 语句指产生了对实例(instance)的调用(call)的 SQL 语句,包括 DML 和 DDL 语句。 |
034 |
When a transaction begins, Oracle assigns the transaction to an
available undo tablespace to record the rollback entries for the new
transaction. |
当一个事务(transaction)开始时,Oracle 为此事务分配一个可用的撤销表空间(undo tablespace)来记录其产生的回滚条目(rollback entry)。 |
035 |
A transaction ends when any of the following occurs:
|
一个事务(transaction)在满足以下条件之一时结束:
|
036 |
After one transaction ends, the next executable SQL statement
automatically starts the following transaction. |
当一个事务(transaction)结束后,下一个可执行的 SQL 语句(executable SQL statement)将会自动地开始一个新事务。 |
037 |
Note: |
提示: |
038 |
Commit Transactions |
4.2.1 事务提交 |
039 |
Committing a transaction means making permanent the changes performed by
the SQL statements within the transaction. |
提交(commit)一个事务(transaction)意味着将此事务中 SQL 语句对数据的修改永久地记录到数据库中。 |
040 |
Before a transaction that modifies data is committed, the following has
occurred:
|
在一个修改了数据的事务(transaction)被提交之前,Oracle进行了以下操作:
|
041 |
Note: |
提示: |
042 |
When a transaction is committed, the following occurs:
|
当事务(transaction)被提交之后,Oracle进行以下操作:
|
043 |
Note: |
提示: |
044 |
|
|
045 |
Rollback of Transactions |
4.2.2 事务回滚 |
046 |
Rolling back means undoing any changes to data that have been
performed by SQL statements within an uncommitted transaction. Oracle
uses undo tablespaces (or rollback segments) to store old values. The
redo log contains a record of changes. |
回滚(rolling back)的含义是撤销一个未提交事务(uncommitted transaction)中已执行的 SQL 语句对数据的修改。Oracle使用撤销表空间(undo tablespace)(或回滚段(rollback segment))来存储被修改的数据的原始值。而重做日志(redo log)内则保存了对数据修改操作的记录。 |
047 |
Oracle lets you roll back an entire uncommitted transaction.
Alternatively, you can roll back the trailing portion of an uncommitted
transaction to a marker called a savepoint. |
用户可以回滚(roll back)整个未提交事务(uncommitted transaction)。除此之外,用户还可以部分回滚未提交事务,即从事务的最末端回滚到事务中任意一个被称为保存点(savepoint)的标记处。 |
048 |
All types of rollbacks use the same procedures:
|
以下各种类型回滚操作(rollback)的过程基本相同:
|
049 |
In rolling back an entire transaction, without referencing any
savepoints, the following occurs:
|
不考虑保存点(savepoint)而回滚(rolling back)整个事务(transaction)的过程如下:
|
050 |
|
|
051 |
Savepoints In Transactions |
4.2.3 事务中的保存点 |
052 |
You can declare intermediate markers called savepoints within the
context of a transaction. Savepoints divide a long transaction into
smaller parts. |
用户在事务(transaction)内可以声明(declare)被称为保存点(savepoint)的标记。保存点将一个大事务划分为较小的片断。 |
053 |
Using savepoints, you can arbitrarily mark your work at any point within
a long transaction. You then have the option later of rolling back work
performed before the current point in the transaction but after a
declared savepoint within the transaction. For example, you can use
savepoints throughout a long complex series of updates, so if you make
an error, you do not need to resubmit every statement. |
用户可以使用保存点(savepoint)在事务(transaction)内的任意位置作标记。之后用户在对事务进行回滚操作(rolling back)时,就可以选择从当前执行位置回滚到事务内的任意一个保存点。例如用户可以在一系列复杂的更新(update)操作之间插入保存点,如果执行过程中一个语句出现错误,用户 可以回滚到错误之前的某个保存点,而不必重新提交所有的语句。 |
054 |
Savepoints are similarly useful in application programs. If a procedure
contains several functions, then you can create a savepoint before each
function begins. Then, if a function fails, it is easy to return the
data to its state before the function began and re-run the function with
revised parameters or perform a recovery action. |
在开发应用程序时也同样可以使用保存点(savepoint)。如果一个过程(procedure)内包含多个函数(function),用户可以在每个函数的开始位置创建一个保存点。当一个函数失败时, 就很容易将数据恢复到函数执行之前的状态,回滚(roll back)后可以修改参数重新调用函数,或执行相关的错误处理。 |
055 |
After a rollback to a savepoint, Oracle releases the data locks obtained
by rolled back statements. Other transactions that were waiting for the
previously locked resources can proceed. Other transactions that want to
update previously locked rows can do so. |
当事务(transaction)被回滚(rollback)到某个保存点(savepoint)后,Oracle将释放由被回滚语句使用的锁。其他等待被锁资源的事务就可以继续执行。需要更新(update)被锁数据行的事务也可以继续执行。 |
056 |
When a transaction is rolled back to a savepoint, the following occurs:
|
将事务(transaction)回滚(roll back)到某个保存点(savepoint)的过程如下:
|
057 |
The transaction remains active and can be continued. |
被部分回滚的事务(transaction)依然处于活动状态,可以继续执行。 |
058 |
Whenever a session is waiting on a transaction, a rollback to savepoint
does not free row locks. To make sure a transaction does not hang if it
cannot obtain a lock, use FOR UPDATE ... NOWAIT
before issuing UPDATE or
DELETE statements. (This refers to locks
obtained before the savepoint to which has been rolled back. Row locks
obtained after this savepoint are released, as the statements executed
after the savepoint have been rolled back completely.) |
一个事务(transaction)在等待其他事务的过程中,进行回滚(roll back)到某个保存点(savepoint)的操作不会释放行级锁(row lock)。为了避免事务因为不能获得锁而被挂起,应在执行 UPDATE 或 DELETE 操作前使用 FOR UPDATE ... NOWAIT 语句。(以上内容讲述的是回滚保存点之前所获得的锁。而在保存点之后获得的行级锁是会被释放的,同时保存点之后执行的 SQL 语句也会被完全回滚)。 |
059 |
Transaction Naming |
4.2.4 事务命名 |
060 |
You can name a transaction, using a simple and memorable text string.
This name is a reminder of what the transaction is about. Transaction
names replace commit comments for distributed transactions, with the
following advantages:
|
用户可以使用一个简单好记的字符串为事务(transaction)命名。事务的名称可以用于提示此事务的内容。在分布式事务(distributed
transaction)中,事务命名(transaction name)已经替代了提交注释(commit comment),因为其具备以下优势:
|
061 |
How Transactions Are Named |
4.2.4.1 如何为事务命名 |
062 |
Name a transaction using the SET TRANSACTION ...
NAME statement before you start the transaction. |
用户可以在事务(transaction)开始前使用 SET TRANSACTION NAME ... 语句为事务命名。 |
063 |
When you name a transaction, you associate the transaction's name with
its ID. Transaction names do not have to be unique; different
transactions can have the same transaction name at the same time by the
same owner. You can use any name that enables you to distinguish the
transaction. |
当为事务(transaction)命名时,相当于将此名称与事务的 ID 绑定。因此事务名不需要唯一,同一时刻同一用户可以为不同的事务赋予相同的事务名,只要此名称对用户来说易于区分即可。 |
064 |
Commit Comment |
4.2.4.2 提交注释 |
065 |
In previous releases, you could associate a comment with a transaction
by using a commit comment. However, a comment can be associated with a
transaction only when a transaction is being committed. |
在之前版本 Oracle 的中,用户可以使用提交注释(commit comment)为事务(transaction)添加一个注释。但是这个注释只能在事务提交时添加。 |
066 |
Commit comments are still supported for backward compatibility. However,
Oracle strongly recommends that you use transaction names. Commit
comments are ignored in named transactions. |
出于与之前版本兼容的考虑,Oracle 仍旧支持提交注释(commit comment)。但 Oracle 强烈建议用户使用事务命名(transaction name)。使用事务命名时,提交注释将被忽略。 |
067 |
Note: |
提示: |
068 |
|
|
069 |
The Two-Phase Commit Mechanism |
4.2.5 两步提交机制 |
070 |
In a distributed database, Oracle must coordinate transaction control
over a network and maintain data consistency, even if a network or
system failure occurs. |
在分布式数据库(distributed
database)中,Oracle 需要在网络环境下进行事务(transaction)控制,并保证数据一致性(data
consistency)。而分布式环境中可能发生各种系统或网络故障。 |
071 |
A distributed transaction is a transaction that includes one or
more statements that update data on two or more distinct nodes of a
distributed database. |
分布式事务(distributed transaction)指同一个事务(transaction)中的一个或多个
SQL 语句同时更新(update)分布式数据库(distributed database)中不同节点(node)的数据。 |
072 |
A two-phase commit mechanism guarantees that all database servers
participating in a distributed transaction either all commit or all undo
the statements in the transaction. A two-phase commit mechanism also
protects implicit DML operations performed by integrity constraints,
remote procedure calls, and triggers. |
两步提交机制(two-phase commit mechanism)可以保证所有参与分布式事务(distributed transaction)的数据库或者同时提交(commit),或者同时撤销(undo)事务中 SQL 语句的操作。两步提交机制还确保了由完整性约束(integrity constraint),远程过程调用(remote procedure call),及触发器(trigger)执行的隐式 DML 操作正常工作。 |
073 |
The Oracle two-phase commit mechanism is completely transparent to users
who issue distributed transactions. In fact, users need not even know
the transaction is distributed. A COMMIT
statement denoting the end of a transaction automatically triggers the
two-phase commit mechanism to commit the transaction. No coding or
complex statement syntax is required to include distributed transactions
within the body of a database application. |
Oracle 两步提交机制(two-phase commit mechanism)对于提交分布式事务(distributed transaction)的用户来说完全透明。用户甚至无需知道其事务是分布式的。当事务由一个 COMMIT 语句标志结束后会自动地触发两步式提交机制来提交此事务。数据库应用程序中无需使用任何代码或复杂的 SQL 语法就能处理分布式事务。 |
074 |
The recoverer (RECO) background process
automatically resolves the outcome of in-doubt distributed
transactions—distributed transactions in which the commit was
interrupted by any type of system or network failure. After the failure
is repaired and communication is reestablished, the
RECO process of each local Oracle database
automatically commits or rolls back any in-doubt distributed
transactions consistently on all involved nodes. |
后台进程(recoverer,RECO)能够自动地处理系统中出现的不可信的分布式事务(in-doubt distributed transaction)。不可信的分布式事务指因为各种系统或网络故障而阻碍了提交(commit)操作的分布式事务。当故障修复,通信恢复后,每个 Oracle 数据库本地的 RECO 进程将自动地提交(commit)或回滚(roll back)不可信的分布式事务,并保证所有参与分布式事务的节点协调一致。 |
075 |
In the event of a long-term failure, Oracle allows each local
administrator to manually commit or undo any distributed transactions
that are in doubt as a result of the failure. This option enables the
local database administrator to free any locked resources that are held
indefinitely as a result of the long-term failure. |
如果系统中的故障暂时无法恢复,Oracle允许数据库 DBA 在本地手工地提交(commit)或撤销(undo)此故障导致的不可信的分布式事务(in-doubt distributed transaction)。这个功能使本地的 DBA 可以释放被不可信的分布式事务锁住的资源。 |
076 |
If a database must be recovered to a point in the past, Oracle's
recovery facilities enable database administrators at other sites to
return their databases to the earlier point in time also. This operation
ensures that the global database remains consistent. |
如果一个分布式环境中的数据库需要恢复(recovery),其他节点的 DBA 可以使用 Oracle 的恢复功能将他们各自管理的数据库也恢复到相同的时间点。这个功能保证了分布式环境中所有数据库的数据一致性(consistent)。 |
077 |
See Also: |
另见: |
078 |
Overview of Autonomous Transactions |
4.3 自治事务概述 |
079 |
Autonomous transactions are independent transactions that can be called
from within another transaction. An autonomous transaction lets you
leave the context of the calling transaction, perform some SQL
operations, commit or undo those operations, and then return to the
calling transaction's context and continue with that transaction. |
如果一个事务(transaction)在另一个事务中被调用,那么这个独立的事务被称为自治事务(autonomous transaction)。用户使用自治事务可以暂时脱离其调用者的事务上下文环境(context),在一个新的事务中执行一系列 SQL 操作(在自治事务内可以对这些操作进行提交(commit)与回滚(undo)),自治事务结束后还可以返回调用者事务的上下文环境继续执行。 |
080 |
Once invoked, an autonomous transaction is totally independent of the
main transaction that called it. It does not see any of the uncommitted
changes made by the main transaction and does not share any locks or
resources with the main transaction. Changes made by an autonomous
transaction become visible to other transactions upon commit of the
autonomous transactions. |
自治事务(autonomous transaction)被调用后与发起调用的事务(transaction)完全独立。她看不到调用者事务内任何未提交(uncommitted)的数据修改,也不能共享调用者事务使用的锁(lock)和其他资源。自治事务提交后,其中所做的数据修改即对其他事务有效。 |
081 |
One autonomous transaction can call another. There are no limits, other
than resource limits, on how many levels of autonomous transactions can
be called. |
自治事务(autonomous transaction)中可以再调用其他自治事务。除了资源上的限制,自治事务调用的嵌套层次没有限制。 |
082 |
Deadlocks are possible between an autonomous transaction and its calling
transaction. Oracle detects such deadlocks and returns an error. The
application developer is responsible for avoiding deadlock situations. |
自治事务(autonomous transaction)与其调用者之间可能会产生死锁(deadlock)。Oracle 会检测此类死锁并返回错误信息。但应用程序开发者应该避免此类死锁的发生。 |
083 |
Autonomous transactions are useful for implementing actions that need to
be performed independently, regardless of whether the calling
transaction commits or rolls back, such as transaction logging and retry
counters. |
有些情况下,无论调用者事务是提交(commit)或回滚(roll back)都需要执行某些独立的操作,此时适合使用自治事务(autonomous transaction)。较长见的应用是事务日志(transaction logging),及重试计数(retry counter)。 |
084 |
Autonomous PL/SQL Blocks |
4.3.1 自治的 PL/SQL 程序结构 |
085 |
You can call autonomous transactions from within a PL/SQL block. Use the
pragma AUTONOMOUS_TRANSACTION. A pragma
is a compiler directive. You can declare the following kinds of PL/SQL
blocks to be autonomous:
|
用户可以通过 pragma 指令
AUTONOMOUS_TRANSACTION 将一个 PL/SQL
程序结构设定为自治事务(autonomous transaction)。pragma
是一个编译器指令(compiler directive)。用户可以将以下类型的 PL/SQL 程序结构定义为自治的:
|
086 |
When an autonomous PL/SQL block is entered, the transaction context of
the caller is suspended. This operation ensures that SQL operations
performed in this block (or other blocks called from it) have no
dependence or effect on the state of the caller's transaction context. |
当一个自治的 PL/SQL 程序结构开始运行时,调用者的事务上下文环境(transaction context)就被挂起。这保证了自治程序结构(或由此自治程序结构调用的其他结构)内的 SQL 操作与调用者的事务上下文环境相独立,且不会对其产生影响。 |
087 |
When an autonomous block invokes another autonomous block or itself, the
called block does not share any transaction context with the calling
block. However, when an autonomous block invokes a non-autonomous block
(that is, one that is not declared to be autonomous), the called block
inherits the transaction context of the calling autonomous block. |
当一个自治程序结构(autonomous block)调用其他程序结构或其自身时,被调用的程序结构不会与调用者共享任何事务上下文环境(transaction context)。但当一个自治程序结构调用一个非自治程序结构(non-autonomous block)时,被调用的程序结构将继承调用者的事务上下文环境。 |
088 |
Transaction Control Statements in Autonomous Blocks |
4.3.1.1 自治程序结构中的事务控制语句 |
089 |
Transaction control statements in an autonomous PL/SQL block apply
only to the currently active autonomous transaction. Examples of
such statements are:SET TRANSACTION |
自治 PL/SQL 程序结构内的事务控制语句(transaction control
statements)仅对当前的自治事务(autonomous transaction)有效。这些控制语句包括:SET TRANSACTION |
090 |
Similarly, transaction control statements in the main transaction apply
only to that transaction and not to any autonomous transaction that it
calls. For example, rolling back the main transaction to a savepoint
taken before the beginning of an autonomous transaction does not undo
the autonomous transaction. |
同样,一个事务(transaction)内的事务控制语句(transaction control statements)也仅对其自身有效,而不会作用于被其调用的自治事务(autonomous transaction)。例如,将一个事务回滚到调用自治事务之前的某个保存点(savepoint),并不会撤消(undo)被调用的自治事务内的任何操作。 |
091 |
See Also: |
另见: |
[085] pragma |
[002] Autonomous Transactions [016] in-doubt distributed transactions [042] system change number [060] transaction auditing redo record [085] Type method [085] Top-level anonymous block |
[055] Other transactions that were waiting
for the previously locked resources can proceed. Other transactions that
want to update previously locked rows can do so. [058] |
[023] Deadlocks [031] Oracle Database Administrator's Guide [044] Oracle Database Application Developer's Guide - Fundamentals [044] Overview of Locking Mechanisms [044] Overview of Oracle Processes [050] Oracle Database Backup and Recovery Basics [068] Oracle Database Administrator's Guide [068] Oracle Database SQL Reference [077] Oracle Database Heterogeneous Connectivity Administrator's Guide [091] Oracle Database PL/SQL User's Guide and Reference |
1、implicit savepoint 是什么? [022] Users cannot directly refer to implicit savepoints in rollback statements. 2、redo log buffer 和 database buffer写入磁盘的时机? [040] 3、对原文的理解不确定。事务提交的原子性操作因该包括几个步骤? [042] This atomic event constitutes the commit of the transaction. 4、[040]与[042]的讲解有矛盾。[040]说 redo log 的写操作可能发生在事务提交之前,而[042]说应发生在事务提交之后。 [040] These changes may go to disk before a transaction is committed. [042] When a transaction is committed, the following occurs 5、不明白。此句中 does not free 的是什么锁? [058] Whenever a session is waiting on a transaction, a rollback to savepoint does not free row locks. 5、具体的版本号 [065] In previous releases, you could associate a comment with a transaction by using a commit comment. 6、此处说的“recovery”是指数据库恢复?还是事务的回滚? [076] If a database must be recovered to a point in the past, Oracle's recovery facilities enable database administrators at other sites to return their databases to the earlier point in time also. |