UNDO -- Concept

 Undo data
  
Records of the actions of transactions, primarily before they are committed. The database can use undo data to logically reverse the effect of SQL statements. Undo data is stored in undo segments.

回滚数据

  事务活动的被提交前的记录。数据库可以使用回滚数据来逻辑地撤销SQL语句的影响。UNDO数据存储在UNDO段中。

Undo Segments
  Oracle Database maintains records of the actions of transactions, collectively known as undo data. Oracle Database uses undo to do the following:
■Roll back an active transaction
■Recover a terminated transaction
■Provide read consistency
■Perform some logical flashback operations
  Oracle Database stores undo data inside the database rather than in external logs. Undo data is stored in blocks that are updated just like data blocks, with changes to these blocks generating redo. In this way, Oracle Database can efficiently access undo data without needing to read external logs.
Undo data is stored in an undo tablespace. Oracle Database provides a fully automated mechanism, known as automatic undo management mode, for managing undo segments and space in an undo tablespace.

UNDO段
ORACLE数据库管理事务活动的记录,收集位UNDO数据。数据库使用UNDO来实现以下功能:
■回滚一个活动的事务
■恢复一个终止的事务
■提供读一致性
■进行一些逻辑闪回操作
ORACLE数据库把undo数据存储在数据库内部而不是外部日志。UNDO数据是存储在块中的,它的更新是跟数据块一样的,对UNDO块的更新同样会产生日志。在这种方式下,ORACLE数据库可以高效地使用undo数据而不用去读外部日志。
UNDO数据存储在UNDO表空间中。ORACLE数据库提供一种全自动的管理机制,即UNDO自动管理模式,用来管理在一个UNDO表空间中管理UNDO段以及空间。

Undo Segments and Transactions
  When a transaction starts, the database binds (assigns) the transaction to an undo segment, and therefore to a transaction table, in the current undo tablespace. In rare circumstances, if the database instance does not have a designated undo tablespace, then the transaction binds to the system undo segment.
Multiple active transactions can write concurrently to the same undo segment or to different segments. For example, transactions T1 and T2 can both write to undo segment U1, or T1 can write to U1 while T2 writes to undo segment U2.
  Conceptually, the extents in an undo segment form a ring. Transactions write to one undo extent, and then to the next extent in the ring, and so on in cyclical fashion. Figure 12–20 shows two transactions, T1 and T2, which begin writing in the third extent (E3) of an undo segment and continue writing to the fourth extent (E4).

UNDO段和事务
当一个事务开始,数据库在当前的UNDO表空间中绑定(分配)一个UNDO段及一个事务表给事务。在少数环境中,如果数据库实例没有一个指定的UNDO表空间,那么事务会绑定SYSTEM的UNOD段。

多个活动的事务可以并发地写一样的UNDO段或者不同的段。比如说,事务T1和T2可以一起写UNDO段U1,或者T1可以写U1,同时T2写U2。
理论上来说,一个UNDO段里面的区是一个圆环的形式。事务在一个UNDO区中写数据,然后是圆环的下一个,一个一个这样子循环往复。
如表格12-20表现的两个事务T1和T2,它们同时在UNDO段的E3区开始写,然后接下来则到了E4区开始写。

  At any given time, a transaction writes sequentially to only one extent in an undo segment, known as the current extent for the transaction. Multiple active transactions can write simultaneously to the same current extent or to different current extents. Figure 12–20 shows transactions T1 and T2 writing simultaneously to extent E3. Within an undo extent, a data block contains data for only one transaction.
  As the current undo extent fills, the first transaction needing space checks the availability of the next allocated extent in the ring. If the next extent does not contain data from an active transaction, then this extent becomes the current extent. Now all transactions that need space can write to the new current extent. In Figure 12–21, when E4 is full, T1 and T2 continue writing to E1, overwriting the nonactive undo data in E1.

  在任意一个给定的时间,一个事务只在一个UNDO段中的一个区上顺序写,称之为事务的当前区。多个活动事务可以同时在同样的或者不同的当前区中写数据。如图12-20所显示的,事务T1和T2同时在写E3区。
在一个UNDO区里面,一个数据块里面的数据只是一个事务的。
当目前的UNDO区填满后,第一个需要空间的事务会检查圆圈的下一个区的可用性。假如下个区不包含活动事务的数据,那么这个区就将变为当前区。然后所有需要空间的事务都会往当前空间里写数据。
在图12-21中,当E4满了后,T1跟T2开始往E1里面写,覆盖掉E1里面的非活动的UNDO数据。

  At any given time, a transaction writes sequentially to only one extent in an undo segment, known as the current extent for the transaction. Multiple active transactions can write simultaneously to the same current extent or to different current extents. Figure 12–20 shows transactions T1 and T2 writing simultaneously to extent E3. Within an undo extent, a data block contains data for only one transaction.
  As the current undo extent fills, the first transaction needing space checks the availability of the next allocated extent in the ring. If the next extent does not contain data from an active transaction, then this extent becomes the current extent. Now all transactions that need space can write to the new current extent. In Figure 12–21, when E4 is full, T1 and T2 continue writing to E1, overwriting the nonactive undo data in E1.

在任意一个给定的时间,一个事务只在一个UNDO段中的一个区上顺序写,称之为事务的当前区。多个活动事务可以同时在同样的或者不同的当前区中写数据。如图12-20所显示的,事务T1和T2同时在写E3区。
在一个UNDO区里面,一个数据块里面的数据只是一个事务的。
当目前的UNDO区填满后,第一个需要空间的事务会检查圆圈的下一个区的可用性。假如下个区不包含活动事务的数据,那么这个区就将变为当前区。然后所有需要空间的事务都会往当前空间里写数据。
在图12-21中,当E4满了后,T1跟T2开始往E1里面写,覆盖掉E1里面的非活动的UNDO数据。

  If the next extent does contain data from an active transaction, then the database must allocate a new extent. Figure 12–22 shows a scenario in which T1 and T2 are writing to E4. When E4 fills up, the transactions cannot continue writing to E1 because E1 contains active undo entries. Therefore, the database allocates a new extent (E5) for this undo segment. The transactions continue writing to E5.

如果下一个区包含活动事务的数据,那么数据库必须分配一个新的区。图12-22显示的场景里,T1和T2正在写E4,当E4满了厚,事务没办法继续写E1,因为E1包含了活动UNDO的记录。所以,数据库分配了一个新的区E5给这个UNDO段,然后事务继续在E5里面写。

Transaction Rollback
  When a ROLLBACK statement is issued, the database uses undo records to roll back changes made to the database by the uncommitted transaction. During recovery, the database rolls back any uncommitted changes applied from the online redo log to the data files. Undo records provide read consistency by maintaining the before image of the data for users accessing data at the same time that another user is changing it.

事务回滚

  当一个“ROLLBACK"语句发出的时候,数据库使用undo记录来回滚未提交的事务变更。在恢复期间,数据库通过应用在线重做日志来回滚任何未提交的变更。UNDO保持数据的前镜像来让用户群获取到正在被其他用户修改的数据,通过这种方式实现了读一致性。

原文地址:https://www.cnblogs.com/ryanw/p/8530066.html

时间: 2024-08-02 10:44:24

UNDO -- Concept的相关文章

Linux TCP拥塞控制中undo操作

Linux的TCP实现复杂且繁琐,建议不要直接去看代码,而是花点时间把TCP规范先撸一遍.本文主要描述一下TCP实现中undo操作,然后顺便再吐一下槽(千万不要觉得吐槽有什么不好,很多好东西都是从吐槽开始的,从造纸,蒸汽机,到法兰西第一共和国,再到Linux...). 1.TCP对网络拥塞是基于预测的 TCP属于网络的一部分,这无可厚非,但当一个人说自己精通网络的时候,他更可能的意思是自己精通网络节点的行为而不是端到端的行为.比如,一个Cisco的工程师精通各种路由协议,可以设计出复杂的OSPF

Oracle Undo 查询表中历史数据

Undo 表空间用于存放Undo 数据.当执行DML操作时,Oracle会将这些操作的旧数据写入Undo 段.用于对数据库 一致读,事务回滚 之类的操作. 换而言之,在特殊情况下,我们可以用它来找回被错误操作的数据.例如: SELECT t.fid   FROM ct_bas_province AS OF TIMESTAMP to_date('2014-11-21 22:01', 'yyyy-mm-dd HH24:mi') t  WHERE t.fnumber = '海南省'; 即在要查询的表名

UNDO segment深入解析

Undo Segment深入解析   在undo自动管理时,设置了undo_retention以后,undo块就存在四种状态. Active:表示正在使用该undo的事务还没有提交或回滚.Inactive:表示该undo上没有活动的事务,该状态的undo可以被其他事务覆盖.Expired:表示该undo持续inactive的时间超过undo_retention所指定的时间.Freed:表示该undo块内容是空的,从来没有被使用过. Undo Retention      After a tran

概念学习(Concept Learning)

这是概念学习的一个简单示例的C++代码. 1 #include <iostream> 2 using namespace std; 3 typedef enum Sky{Sunny,Rainy}Sky; 4 typedef enum AirTemp{Warm,Cold,Cool}AirTemp; 5 typedef enum Humidity{Normal,High}Humidity; 6 typedef enum Wind{Strong}Wind; 7 //typedef enum Wate

undo/redo功能的原理和思路

一些具有操作记录的系统,如店铺装修.富文本编辑等,都具有undo/redo功能,可实现界面操作过程的撤销和恢复,简述开发undo/redo功能的原理和思路. undo是将用户上一步做的操作对程序造成的改动恢复到改动之前,而redo操作是指重新实现这种改动. undo/redo操作的实现方式分为两类:记录数据和记录操作. 记录数据是指将信息编辑窗口打开时,保存原始数据,然后记录用户每次操作后的结果数据,这里的数据是指信息编辑窗口中所有可能发生变动的数据.做undo操作时程序将用户上一步操作前的数据

说说MySQL中的Redo log Undo log都在干啥

阅读目录(Content) 1 undo 1.1 undo是啥 1.2 undo参数 1.3 undo空间管理 2 redo 2.1 redo是啥 2.2 redo 参数 2.3 redo 空间管理 3 undo及redo如何记录事务 3.1 Undo + Redo事务的简化过程 3.2  IO影响 3.3 恢复 在数据库系统中,既有存放数据的文件,也有存放日志的文件.日志在内存中也是有缓存Log buffer,也有磁盘文件log file,本文主要描述存放日志的文件. MySQL中的日志文件,

Oracle 12c 多租户 CDB 与 PDB之 shared undo 与 Local undo 切换

undo 在12C R1版本中只支持Global Shared Undo模式, 所有container共享一个UNDO表空间, 目前保留这种模式只是为了升级过渡, 在12C R2引入了PDB Local UNDO模式,每个container都有自己的UNDO 表空间, 对于RAC是每个实例每个container都有自己的UNDO表空间, 这也正是推荐的.在DBCA时会有local undo选项,且默认勾选. local undo 模式的好处:1.减少undo表空间的争用,同时方便拔插 2.只有使

oracle undo回滚段详解

1.Undo是干嘛用的?   在介绍undo之前先说一下另外一个东西 transaction ,翻译成交易或事务.我们在进行一个事务的过程中需要申请许多资源,一个复杂的事务也需要很多步来完成.那么一个复杂的事务是只有两个结果,要么成功,要么失败(相当于从来没发生过). 一个很典型的列子,银行转账,其实其需要两步操作,第一步先将你账户上的钱减去,第二步把被转账户的钱加上,(先减后加,出了问题银行不吃亏.呵呵!)这样就是一个完整的事务.如果执行了一半,你的钱减了,被转账户的钱没加上,这个时候事务就要

【转载】MySQL 日志 undo | redo

本文是介绍MySQL数据库InnoDB存储引擎重做日志漫游 00 – Undo LogUndo Log 是为了实现事务的原子性,在MySQL数据库InnoDB存储引擎中,还用Undo Log来实现多版本并发控制(简称:MVCC). - 事务的原子性(Atomicity)  事务中的所有操作,要么全部完成,要么不做任何操作,不能只做部分操作.如果在执行的过程中发生  了错误,要回滚(Rollback)到事务开始前的状态,就像这个事务从来没有执行过. - 原理  Undo Log的原理很简单,为了满