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保持数据的前镜像来让用户群获取到正在被其他用户修改的数据,通过这种方式实现了读一致性。
Managing Undo Tablespaces
This section describes the various steps involved in undo tablespace management and contains the following sections:
■ Creating an Undo Tablespace
■ Altering an Undo Tablespace
■ Dropping an Undo Tablespace
■ Switching Undo Tablespaces
■ Establishing User Quotas for Undo Space
■ Undo Space Data Dictionary Views
管理undo表空间
这一章节描述undo表空间管理的多个步骤,包含以下章节:
■ 创建undo表空间
■ 修改undo表空间
■ 删除undo表空间
■ 切换undo表空间
■ 设置用户undo表空间配额
■ undo空间数据字典视图
Creating an Undo Tablespace
Although Database Configuration Assistant (DBCA) automatically creates an undo tablespace for new installations of Oracle Database Release 11g, there may be occasions when you want to manually create an undo tablespace.
There are two methods of creating an undo tablespace. The first method creates the undo tablespace when the CREATE DATABASE statement is issued. This occurs when you are creating a new database, and the instance is started in automatic undo management mode (UNDO_MANAGEMENT = AUTO). The second method is used with an
existing database. It uses the CREATE UNDO TABLESPACE statement.
You cannot create database objects in an undo tablespace. It is reserved for system-managed undo data.
Oracle Database enables you to create a single-file undo tablespace. Single-file, or bigfile
Using CREATE DATABASE to Create an Undo Tablespace
You can create a specific undo tablespace using the UNDO TABLESPACE clause of the CREATE DATABASE statement.
The following statement illustrates using the UNDO TABLESPACE clause in a CREATE DATABASE statement. The undo tablespace is named undotbs_01 and one data file,
/u01/oracle/rbdb1/undo0101.dbf, is allocated for it.
CREATE DATABASE rbdb1
CONTROLFILE REUSE
.
.
.
UNDO TABLESPACE undotbs_01 DATAFILE '/u01/oracle/rbdb1/undo0101.dbf';
If the undo tablespace cannot be created successfully during CREATE DATABASE, the entire CREATE DATABASE operation fails. You must clean up the database files, correct the error and retry the CREATE DATABASE operation.
The CREATE DATABASE statement also lets you create a single-file undo tablespace at database creation. This is discussed in "Supporting Bigfile Tablespaces During Database Creation" on page 2-20.
Using the CREATE UNDO TABLESPACE Statement
The CREATE UNDO TABLESPACE statement is the same as the CREATE TABLESPACE statement, but the UNDO keyword is specified. The database determines most of the
attributes of the undo tablespace, but you can specify the DATAFILE clause.
This example creates the undotbs_02 undo tablespace with the AUTOEXTEND option:
创建undo表空间
虽然在11G的时候使用dbca创建新数据库的时候会自动创建一个undo表空间,某些情况下你仍然可能需要手动创建undo表空间。
有两种方式可以创建undo表空间。
第一种方式是在通过CREATE DATABASE语句创建数据库的时候创建。这发生在你创建新数据库的时候,实例以自动undo管理模式启动(UNDO_MANAGEMENT = AUTO)。
第二种方式是在现有的数据库中通过create undo tablespace来创建。
你不能在undo表空间中创建数据库对象。它是保留用于系统管理undo数据的。
oracle数据库允许你创建单文件undo表空间。单文件,或者bigfile。
UNDO -- Concept的更多相关文章
- Qt's Undo Framework
Overview of Qt's Undo Framework Introduction Qt's Undo Framework is an implementation of the Command ...
- FAQ – Automatic Undo Management (AUM) / System Managed Undo (SMU) (Doc ID 461480.1)
FAQ – Automatic Undo Management (AUM) / System Managed Undo (SMU) (Doc ID 461480.1) APPLIES TO: Orac ...
- MySQL,MariaDB:Undo | Redo [转]
本文是介绍MySQL数据库InnoDB存储引擎重做日志漫游 00 – Undo LogUndo Log 是为了实现事务的原子性,在MySQL数据库InnoDB存储引擎中,还用Undo Log来实现多版 ...
- iOS: 为画板App增加 Undo/Redo(撤销/重做)操作
这个随笔的内容以上一个随笔为基础,(在iOS中实现一个简单的画板),上一个随笔实现了一个简单的画板: 今天我们要为这个画板增加Undo/Redo操作,当画错了一笔,可以撤销它,或者撤销之后后悔了, ...
- 【msql】关于redo 和 undo log
InnoDB 有两块非常重要的日志,一个是undo log,另外一个是redo log,前者用来保证事务的原子性以及InnoDB的MVCC,后者用来保证事务的持久性.和大多数关系型数据库一样,Inno ...
- [转]undo log与redo log原理分析
数据库通常借助日志来实现事务,常见的有undo log.redo log,undo/redo log都能保证事务特性,这里主要是原子性和持久性,即事务相关的操作,要么全做,要么不做,并且修改的数据能得 ...
- [转]MySQL日志——Undo | Redo
本文是介绍MySQL数据库InnoDB存储引擎重做日志漫游 00 – Undo LogUndo Log 是为了实现事务的原子性,在MySQL数据库InnoDB存储引擎中,还用Undo Log来实现多版 ...
- 【转】ORACLE的REDO与UNDO
一.什么是redo?redo:oracle在在线或者归档重做日志文件中的记录的信息,外以出现失败时可以利用这些数据来"重放"事务.每个oracle数据都至少有二个在线重做日志组,每 ...
- oracle undo回滚段详解
1.Undo是干嘛用的? 在介绍undo之前先说一下另外一个东西 transaction ,翻译成交易或事务.我们在进行一个事务的过程中需要申请许多资源,一个复杂的事务也需要很多步来完成.那么一个 ...
随机推荐
- python的库小全
环境管理 管理 Python 版本和环境的工具 p – 非常简单的交互式 python 版本管理工具. pyenv – 简单的 Python 版本管理工具. Vex – 可以在虚拟环境中执行命令. v ...
- debian9升级安装到python3.6和pip3.6
安装步骤 1.添加testing源 vim /etc/apt/sources.list deb http://mirrors.163.com/debian/ testing main 2.更新源 ap ...
- js 闭包,作用域,this 终结篇(转)
之前有写过闭包,作用域,this方面的文章,但现在想想当时写的真是废话太多了,以至于绕来绕去的,让新手反而更难理解了,所以就有了此篇文章,也好和闭包,作用域,this告一段落. 第一个问题:什么是闭包 ...
- CentOS7 配置ISCSI targetcli 共享存储
- Mysql AVG() 值 返回NULL而非空结果集
[1]select 查询返回一行NULL 先来模拟复现一下遇到的问题. (1)源数据表grades,学生成绩表 (2)查询SQL语句 查询‘080601’班的各门课平均成绩 SELECT sClass ...
- 宝塔安装swoole
新建文件夹 mkdir swoole 切入到文件夹中,进行下载安装包 wget http://pecl.php.net/get/swoole-4.3.2.tgz 解压 tar -zxvf swoole ...
- [dart学习]第四篇:函数和操作符(本篇未完待续)
接着学习dart的函数和操作符. 1.函数Function dart是一种真正的面向对象的语言,通常一个函数也是Function类型的对象,这也就是说可以把函数赋值给一个变量,或者作为另一个函数的入参 ...
- flutter packages.
connectivity This plugin allows Flutter apps to discover network connectivity and configure themselv ...
- VMware centos7 如何配置静态ip并且可上网
注:此贴使用NAT方式配置上网模式. 1.设置虚拟机的网络适配器为NAT模式: 2.修改VMware的“虚拟网络编辑器”: 打开后选择NAT模式,勾选,然后点击NAT设置: NAT默认设置了188网段 ...
- [Python数据挖掘]第5章、挖掘建模(上)
一.分类和回归 回归分析研究的范围大致如下: 1.逻辑回归 #逻辑回归 自动建模 import pandas as pd from sklearn.linear_model import Logist ...