码迷,mamicode.com
首页 > 其他好文 > 详细

UNDO -- Concept

时间:2018-03-11 14:44:45      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:use   auto   term   main   show   hat   重做日志   opera   rar   

 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保持数据的前镜像来让用户群获取到正在被其他用户修改的数据,通过这种方式实现了读一致性。

UNDO -- Concept

标签:use   auto   term   main   show   hat   重做日志   opera   rar   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!