Oracle Database Administration/Undo Data
Appearance
This lesson introduces Oracle database undo data.
Objectives and Skills
[edit | edit source]Objectives and skills for the undo data portion of Oracle Database Administration I certification include:[1]
- Managing Undo Data
- Overview of Undo
- Transactions and undo data
- Managing undo
Readings
[edit | edit source]Multimedia
[edit | edit source]Activities
[edit | edit source]- Complete the tutorial Oracle: Managing Database Storage Structures.
- View Undo storage.
- Use the following queries to view undo tablespaces and rollback segments:
SELECT * FROM DBA_TABLESPACES WHERE CONTENTS = 'UNDO';
SELECT * FROM V$PARAMETER WHERE NAME = 'undo_tablespace';
SELECT * FROM DBA_ROLLBACK_SEGS;
- Use the following queries to view undo statistics:
SELECT * FROM V$ROLLSTAT;
SELECT * FROM V$UNDOSTAT;
- Use the following queries to view undo tablespaces and rollback segments:
- View transactions.
- Use the following query to begin a transaction:
INSERT INTO HR.REGIONS VALUES (5, 'Antarctica');
- Use the following query to view transaction information:
SELECT * FROM V$TRANSACTION;
- Open a second connection to the database and use the following query to select HR REGIONS:
SELECT * FROM HR.REGIONS;
- Use the following query in the first session to roll back the transaction:
ROLLBACK;
- Use the following queries to verify the transaction was rolled back:
SELECT * FROM V$TRANSACTION;
SELECT * FROM HR.REGIONS;
- Use the following query to begin a transaction:
- Use Flashback.
- Use the following query to view HR REGIONS as of an hour ago:
SELECT * FROM HR.REGIONS AS OF TIMESTAMP (SYSTIMESTAMP - 1 / 24);
- Use Enterprise Manager Database Control / Server / Automatic Undo Management / Edit Undo Retention to set the undo retention to 3600 seconds (1 hour).
- Use the following query to configure undo retention to 86400 seconds (1 day):
ALTER SYSTEM SET UNDO_RETENTION = 86400;
- Use the following query to view HR REGIONS as of an hour ago:
- Create undo tablespaces.
- Use Enterprise Manager Database Control / Server / Tablespaces to create an undo tablespace named UNDOTBS2 with a datafile named UNDOTBS02.
- Use the following query to identify the location of existing datafiles:
SELECT NAME FROM V$DATAFILE;
- Use the following query to create an undo tablespace:
CREATE UNDO TABLESPACE UNDOTBS3
DATAFILE '<data file path>\UNDOTBS03.DBF'
SIZE 1M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;
- Manage undo tablespaces.
- Use Enterprise Manager Database Control / Server / Tablespaces to edit UNDOTBS2 and enable Undo Retention Guarantee.
- Use Enterprise Manager Database Control / Server / Automatic Undo Management to change the undo tablespace to UNDOTBS2.
- Use the following query to enable undo retention guarantee on UNDOTBS3:
ALTER TABLESPACE UNDOTBS3 RETENTION GUARANTEE;
- Use the following query to change the undo tablespace to UNDOTBS3:
ALTER SYSTEM SET UNDO_TABLESPACE = 'UNDOTBS3';
- Delete undo tablespaces.
- Use Enterprise Manager Database Control / Server Automatic Undo Management and Tablespaces or the following queries to change the undo tablespace to UNDOTBS1 and delete the tablespaces UNDOTBS2 and UNDOTBS3:
ALTER SYSTEM SET UNDO_TABLESPACE = 'UNDOTBS1';
DROP TABLESPACE UNDOTBS2;
DROP TABLESPACE UNDOTBS3;
- Use Enterprise Manager Database Control / Server Automatic Undo Management and Tablespaces or the following queries to change the undo tablespace to UNDOTBS1 and delete the tablespaces UNDOTBS2 and UNDOTBS3:
See Also
[edit | edit source]References
[edit | edit source]