日期:2014-05-16  浏览次数:20495 次

第11章 Managing Undo Data(管理撤销数据)

certification objectives


  • Explain the Purpose of Undo
  • Understand How Transactions Generate Undo
  • Manage Undo

认证目标:


  • 解释撤销的目的
  • 理解事务如何产生的撤销
  • 管理撤销

Chapter 10 described what happens in memory,and on disk,when you execute INSERT,UPDATE,or DELETE statements-the manner in which changed data is written to blocks of table and index segments,and the old version of the data is written out to blocks of an undo segment.It also covered the theory behind this,summarized as the ACID test,which every relational database must pass.In this chapter you will see the practicalities of how undo data is managed.

第10章描述了内存和硬盘中发生了什么,当你执行INSERT,UPDATE或DELETE语句-这种更改数据的举动会写入表和索引段的块,上一版本的数据会写入一个撤销段。本章也涵盖了这背后的理论,就如同ACID测试(任何关系数据库必须通过)总结的那样。本章你将会看到撤销数据如何被管理的实际例子。


Explain the Purpose of Undo


Undo data is the information needed to reverse the effects of DML statements.It is often refered to as rollback data,but try tio avoid that term.In earlier releases of Oracle.the terms rollback data ?and undo data were used interchangeably,but from 9i onward they are different:their function is the same,but their management is not.Whenever a transaction changes data,the preupdate version of the data is written out to a rollback segment or to an undo segment.The difference is crucial.Rollback segments can still exist in an 11g database,but with release 9i of the database Oracle introduced the undo segment as an alternative,Oracle strongly advises that all databases should use undo segments-rollback segmetns are retained for backward compatibility,but they are not referenced in the OCP exam and are therefore not covered in this book.But even though "rollback" as as noun should no longer be used in the Oracle environment "rollback" as a verb is as relevant as ever.

撤销数据是反转DML结果的必要信息。它常常被当做回滚数据,但是尽量避免如此理解这个术语。在Oracle的早期版本中,回滚数据和撤销数据这2个术语是可以相互交换的。但是从9i开始它们就不同了,正准备更新版本的数据写入回滚段或撤销段。这个不同很重要。回滚段在11g中仍然存在,但根据9i版本的介绍,撤销段只是可供选择的,Oracle强烈建议所有的数据库都应该使用撤销段-为了向后兼容回滚段也将继续保留。但是它们在OCP考试中并没有提及,因此本书中没有介绍。尽管rollback作为一个名词将不会再Oracle环境中使用,但是rollback作为一个动词仍然像以前一样重要。

?

To rollback a transaction means to use data from the undo segments to construct an image of the data as it was before the transaction occurred.This is usually done automatically to satisfy the requirements of the ACID test,but the flashback query capacity(introduced with 9i and greatly enhanced since) leverages the power of the undo mechanism by giving you the option of querying the database as it was at some time in the past.And of course ,any user can use the ROLLBACK command interactively to back out any DML statements that he/she has issued and not committed.