Managing the UNDO TABLESPACE

Every Oracle Database must have a method of maintaining information that is used to roll back, or undo, changes to the database. Such information consists of records of the actions of transactions, primarily before they are committed. These records are collectively referred to as undo.

Undo records are used to:

  • Roll back transactions when a ROLLBACK statement is issued
  • Recover the database
  • Provide read consistency
  • Analyze data as of an earlier point in time by using Flashback Query
  • Recover from logical corruptions using Flashback features

Earlier releases of Oracle Database used rollback segments to store undo. Oracle 9i introduced automatic undo management, which simplifies undo space management by eliminating the complexities associated with rollback segment management. Oracle strongly recommends that you use undo tablespace to manage undo rather than rollback segments.

Switching to Automatic Management of Undo Space

To go for automatic management of undo space set the following parameter.

Steps:-

1    If you have not created an undo tablespace at the time of creating a database then, create an undo tablespace by typing the following command

SQL>create undo tablespace myundo datafile  
         ‘/u01/oracle/ica/undo_tbs.dbf’ size 500M
                        autoextend ON next 5M ;

When the system is first running in the production environment, you may be unsure of the space requirements of the undo tablespace. In this case, you can enable automatic extension for datafiles of the undo tablespace so that they automatically increase in size when more space is needed

2.    Shutdown the Database and set the following parameters in parameter file.

UNDO_MANAGEMENT=AUTO
UNDO_TABLESPACE=myundo

3.    Start the Database.

Now Oracle Database will use Automatic Undo Space Management.

Calculating the Space Requirements For Undo Retention

You can calculate space requirements manually using the following formula:

UndoSpace = UR * UPS + overhead

where:

  • UndoSpace is the number of undo blocks
  • UR is UNDO_RETENTION in seconds. This value should take into consideration long-running queries and any flashback requirements.
  • UPS is undo blocks for each second
  • overhead is the small overhead for metadata (transaction tables, bitmaps, and so forth)

As an example, if UNDO_RETENTION is set to 3 hours, and the transaction rate (UPS) is 100 undo blocks for each second, with a 8K block size, the required undo space is computed as follows:

(3 * 3600 * 100 * 8K) = 8.24GBs

To get the values for UPS, Overhead query the V$UNDOSTAT view. By giving the following statement

SQL> Select * from V$UNDOSTAT;

Altering UNDO Tablespace

If the Undo tablespace is full, you can resize existing datafiles or add new datafiles to it

The following example extends an existing datafile

SQL> alter database datafile ‘/u01/oracle/ica/undo_tbs.dbf’ resize 700M

The following example adds a new datafile to undo tablespace

SQL> ALTER TABLESPACE myundo ADD DATAFILE ‘/u01/oracle/ica/undo02.dbf‘ SIZE 200M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;

Dropping an Undo Tablespace

Use the DROP TABLESPACE statement to drop an undo tablespace. The following example drops the undo tablespace undotbs_01:

SQL> DROP TABLESPACE myundo;

An undo tablespace can only be dropped if it is not currently used by any instance. If the undo tablespace contains any outstanding transactions (for example, a transaction died but has not yet been recovered), the DROP TABLESPACE statement fails.

Switching Undo Tablespaces

You can switch from using one undo tablespace to another. Because the UNDO_TABLESPACE initialization parameter is a dynamic parameter, the ALTER SYSTEM SET statement can be used to assign a new undo tablespace.

The following statement switches to a new undo tablespace:

ALTER SYSTEM SET UNDO_TABLESPACE = myundo2;

Assuming myundo is the current undo tablespace, after this command successfully executes, the instance uses myundo2 in place of myundo as its undo tablespace.

Viewing Information about Undo Tablespace

To view statistics for tuning undo tablespace query the following dictionary

SQL>select * from v$undostat;

To see how many active Transactions are there and to see undo segment information give the following command

SQL>select * from v$transaction;

To see the sizes of extents in the undo tablespace give the following query

SQL>select * from DBA_UNDO_EXTENTS;

原文地址:https://www.cnblogs.com/yaoyangding/p/12247130.html

时间: 2024-08-25 16:03:25

Managing the UNDO TABLESPACE的相关文章

How manager undo tablespace

What is the undo data ? 事务在修改数据块时,oracle db会copy修改前的数据块到undo tablespace,这个数据块称之为undo data. Why oracle db needs undo data ? 1.回滚未提交的事务 2.确保数据库一致性读 3.支持oracle flashback功能 What is the undo tablespace? 存放undo data的表空间称之为undo 表空间.undo tbs空间可以重复使用. Undo Re

Oracle Undo tablespace恢复(无备份)

Oracle Undo tablespace恢复 系统环境:   操作系统:RedHat EL55   Oracle:  Oracle 11gR2   Oracle 9i后,采用了undo tablespace管理undo数据,实现undo的自动管理,本案例演示了undo表空间被破坏后如何恢复:如果有备份,通过备份恢复非常容易,但在没有备份的情况下,就需要采用非常规手段来恢复了,呵呵. 1.案例应用环境 undo表空间undo segments: 14:34:44 [email protecte

Innodb独立的undo tablespace

[MySQL5.6] Innodb独立的undo tablespace 在MySQL5.6中开始支持把undo log分离到独立的表空间,并放到单独的文件目录下:这给我们部署不同IO类型的文件位置带来便利,对于并发写入型负载,我们可以把undo文件部署到单独的高速存储设备上. 1.使用 有几个参数来控制该行为 #innodb_undo_tablespaces 用于设定创建的undo表空间的个数,在Install db时初始化后,就再也不能被改动了: 默认值为0,表示不独立设置undo的table

undo tablespace RETENTION GUARANTEE

DBA_TABLESPACES中的RETENTION列说明: Undo tablespace retention: GUARANTEE---Tablespace is an undo tablespace with RETENTION specified as GUARANTEE A RETENTION value of GUARANTEE indicates that unexpired undo in all undo segments in the undo tablespace shou

【12C考题精解】OCP 1z0-060 QUESTION 3: Managing the SYSAUX Tablespace

QUESTION 3 Which two statements are true about the use of the procedures listed in the v$sysaux_occupants.move_procedure column? A. The procedure maybe used for some component store locate component data to the SYSAUX tablespace from its current tabl

UNDO TABLESPACE切换后,旧的长时间没有完全OFFLINE,案列:

案列: 由于生产库impdp导入一个分区表,期间出了问题,终止了导入,但是undo tablespace增长飞快增长到300G了,且经过两天才降下来,但是undo tablespace如果是自动扩展,只会扩展,当事务都结束了它自己也不会收缩的,所以只能手工去收缩. 于是创建一组新的undo tablespace,命名为undotbs2 alter system set undo_tablespace=undotbs2; 在线切换了undo tablespace; 手工切换完了但是还不能立即将旧的

InnoDB undo tablespace使用及原理

前言 Undo log是InnoDB MVCC事务特性的重要组成部分,对记录做了变更操作时会产生undo记录,默认存储到系统表空间中,但是从5.6开始,可以使用独立的undo表空间. Undo记录存储的是老版本数据,当一个旧事务需要读取数据时,为了能读取到老版本数据,需要顺着undo连找到满足其可见性的记录.当版本链很长时,可以认为这是要一个比较耗时的操作. 大多数对记录的变更insert.update.delete.Insert操作在事务提交前只对当前事务可见,因此产生的undo日志可以在事务

ORA-01555 When Max Query Length Is Less Than Undo Retention, small or 0 Seconds (Doc ID 1131474.1)

APPLIES TO: Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.2 [Release 10.2 to 11.2]Oracle Database - Enterprise Edition - Version 11.2.0.3 to 11.2.0.4 [Release 11.2]Oracle Database - Enterprise Edition - Version 12.1.0.2 to 12.1.0.

16 Managing Undo

从Oracle11g开始,在默认安装中oracle会自动管理undo, 典型安装中不需要DBA介入配置,然而,如果选择了flash back特性,你就需要进行一些undo管理任务,来保证flashback特性的成功执行. 本章包含如下内容: 什么是undo 自动undo管理介绍 设置最小undo保留时间 设置固定大小的undo表空间 管理undo表空间 迁 移到自动undo段管理 undo空间数据字典视图 See Also: Chapter 17, "Using Oracle Managed F