After completing this lesson, you should be able to do the following: • Describe the purpose of undo data • Implement Automatic Undo Management • Create and configure undo segments • Obt
Trang 1Managing Undo Data
Trang 2After completing this lesson, you should be able to do the following:
• Describe the purpose of undo data
• Implement Automatic Undo Management
• Create and configure undo segments
• Obtain undo segment information
Trang 3Managing Undo Data
• There are two methods for managing undo data:
– Automatic Undo Management
– Manual Undo Management
• The term undo was known as rollback in previous versions.
Trang 4Undo Segment
Update transaction
Old image
New image Undo segment
Table
Trang 5Undo Segments: Purpose
Transaction rollback Transaction
recovery Undo segment Read consistency
Trang 7Types of Undo Segments
• SYSTEM: Used for objects in the SYSTEM tablespace
• Non-SYSTEM: Used for objects in other tablespaces:
– Auto mode: Requires an UNDO tablespace
– Manual mode:
Private: Acquired by a single instance Public: Acquired by any instance
• Deferred: Used when tablespaces are taken offline immediate,
temporary, or for recovery
Trang 8Automatic Undo Management: Concepts
• Undo data is managed using an UNDO tablespace.
• You allocate one UNDO tablespace per instance with enough space for the workload of the instance.
• The Oracle server automatically maintains undo data within the UNDO tablespace.
Trang 9Automatic Undo Management: Configuration
• Configure two parameters in the initialization file:
Trang 10Automatic Undo Management:
Trang 11Automatic Undo Management:
UNDO Tablespace
Create the UNDO tablespace with the database by
adding a clause in the CREATE DATABASE command:
Or create it later by using the CREATE UNDO
CREATE DATABASE db01
.
UNDO TABLESPACE undo1
DATAFILE '/u01/oradata/undoldb01.dbf' SIZE 20M AUTOEXTEND ON
CREATE UNDO TABLESPACE undo1
DATAFILE '/u01/oradata/undo1db01.dbf'
Trang 12Automatic Undo Management:
Altering an UNDO Tablespace
• The ALTER TABLESPACE command can make changes to UNDO
tablespaces.
• The following example adds another data file to the UNDO tablespace:
ALTER TABLESPACE undotbs
ADD DATAFILE '/u01/oradata/undotbs2.dbf'
SIZE 30M
AUTOEXTEND ON;
Trang 13Automatic Undo Management:
Switching UNDO Tablespaces
• You can switch from using one UNDO tablespace to another.
• Only one UNDO tablespace can be in assigned to a database at a time.
• More than one UNDO tablespace may exist within an instance, but only one can be active.
• Use the ALTER SYSTEM command for dynamic switching between UNDO tablespaces.
ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2;
Trang 14Automatic Undo Management:
Dropping an UNDO Tablespace
• The DROP TABLESPACE command drops an UNDO tablespace.
• An UNDO tablespace can only be dropped if it is currently not in use by any instance.
• To drop an active UNDO tablespace:
– Switch to a new UNDO tablespace.
– Drop the tablespace after all current transactions are
complete.
DROP TABLESPACE UNDOTBS2;
Trang 15Automatic Undo Management:
Other Parameters
• UNDO_SUPPRESS_ERRORS parameter:
– Set to TRUE, this parameter suppresses errors while attempting to execute manual operations in AUTO mode.
• UNDO_RETENTION parameter:
– This parameter controls the amount of undo data to
retain for consistent read.
Trang 16Undo Data Statistics
SELECT end_time,begin_time,undoblks
FROM v$undostat;
END_TIME BEGIN_TIME UNDO - - - 22-JAN-01 13:44:18 22-JAN-01 13:43:04 19 22-JAN-01 13:43:04 22-JAN-01 13:33:04 1474 22-JAN-01 13:33:04 22-JAN-01 13:23:04 1347 22-JAN-01 13:23:04 22-JAN-01 13:13:04 1628 22-JAN-01 13:13:04 22-JAN-01 13:03:04 2249 22-JAN-01 13:03:04 22-JAN-01 12:53:04 1698 22-JAN-01 12:53:04 22-JAN-01 12:43:04 1433 22-JAN-01 12:43:04 22-JAN-01 12:33:04 1532 22-JAN-01 12:33:04 22-JAN-01 12:23:04 1075
Trang 17Automatic Undo Management:
Sizing an UNDO Tablespace
Determining a size for the UNDO tablespace requires three pieces of information:
• (UR) UNDO_RETENTION in seconds
• (UPS) Number of undo data blocks generated per second
• (DBS) Overhead varies based on extent and file size (db_block_size)
Trang 18Automatic Undo Management:
• UNDO_POOL, a Resource Manager directive, defines the amount of space
allowed for a resource group.
• When a group exceeds its limit, no new transactions are possible for the group, until undo space is freed by current transactions which are either completing or aborting.
Trang 19Obtaining Undo Segment Information
• Information about undo segments can be obtained by querying the following views:
Trang 20Summary
In this lesson, you should have learned how to:
• Configure Automatic Undo Management
• Create an UNDO tablespace
• Properly size an UNDO tablespace
• Obtain undo segment information
Trang 21Practice 10 Overview
This practice covers the following topics:
• Creating an UNDO tablespace
• Switching between UNDO tablespaces
• Dropping an UNDO tablepsace