0% found this document useful (0 votes)
2 views29 pages

Les 12 FB DB

The document outlines the objectives and procedures for enabling row movement, performing Flashback Table and Database operations, and configuring Flashback Data Archives in Oracle databases. It details the necessary privileges, commands, and considerations for executing these operations effectively. Additionally, it discusses monitoring Flashback Database capabilities and the restrictions associated with Flashback Data Archives.

Uploaded by

nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views29 pages

Les 12 FB DB

The document outlines the objectives and procedures for enabling row movement, performing Flashback Table and Database operations, and configuring Flashback Data Archives in Oracle databases. It details the necessary privileges, commands, and considerations for executing these operations effectively. Additionally, it discusses monitoring Flashback Database capabilities and the restrictions associated with Flashback Data Archives.

Uploaded by

nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 29

12

Additional Flashback Operations

Copyright © 2007, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to:


• Enable row movement on a table
• Perform Flashback Table operations
• Configure Flashback Database
• Perform Flashback Database operations
• Monitor Flashback Database
• Set up and use a Flashback Data Archive

12 - 2 Copyright © 2007, Oracle. All rights reserved.


Flashback Table: Overview

• Flashback Table recovers tables to a specific point in time.


• Flashback Table is an in-place operation.
• The database stays online.

Erroneous Flashed back


DMLs User tables

12 - 3 Copyright © 2007, Oracle. All rights reserved.


Flashback Table

• Using Flashback Table, you can recover a table or tables to


a specific point in time without restoring a backup.
• Data is retrieved from the undo tablespace to perform a
Flashback Table operation.
• You require the FLASHBACK ANY TABLE or the FLASHBACK
object privilege on the specific table.
• SELECT, INSERT, DELETE, and ALTER privileges on the
table to be flashed back are required.
• You must enable row movement on the table that you are
performing the flashback operation on.

12 - 4 Copyright © 2007, Oracle. All rights reserved.


Enabling Row Movement on a Table

ALTER TABLE employees ENABLE ROW MOVEMENT;

12 - 5 Copyright © 2007, Oracle. All rights reserved.


Performing Flashback Table

FLASHBACK TABLE hr.departments TO TIMESTAMP


TO_TIMESTAMP('2007-04-05 21:00:00',
'YYYY-MM-DD HH24:MI:SS');

12 - 6 Copyright © 2007, Oracle. All rights reserved.


Flashback Table: Considerations

• The FLASHBACK TABLE command executes as a single


transaction, acquiring exclusive DML locks.
• Statistics are not flashed back.
• Current indexes and dependent objects are maintained.
• Flashback Table operations:
– Cannot be performed on system tables
– Cannot span DDL operations
– Generate undo and redo data

12 - 7 Copyright © 2007, Oracle. All rights reserved.


Flashback Database

The Flashback Database operation:


• Works like a rewind button for the database
• Can be used in cases of logical data corruptions made by
users

Errors are The "Press the rewind button" The


generated. database is (FLASHBACK DATABASE). database is
corrupted. "rewound."

12 - 8 Copyright © 2007, Oracle. All rights reserved.


Flashback Database Architecture

SGA
Not every Redo log
Flashback
change! buffer
Buffer cache
buffer LGWR
Every
change

Log block
before
images
periodically.
Flashback Redo
RVWR logs
logs

Back out changes Do forward


1 to database using media recovery. 2
before images.
… …

12 - 9 Copyright © 2007, Oracle. All rights reserved.


Configuring Flashback Database

1. Configure the 2. Set the retention 3. Enable Flashback


flash recovery area. target. Database.
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT EXCLUSIVE;
SQL> ALTER SYSTEM SET
2 DB_FLASHBACK_RETENTION_TARGET=2880
SCOPE=BOTH;
SQL> ALTER DATABASE FLASHBACK ON;
SQL> ALTER DATABASE OPEN;

12 - 10 Copyright © 2007, Oracle. All rights reserved.


Configuring Flashback Database Using EM

Make sure that the database is in ARCHIVELOG mode.

12 - 11 Copyright © 2007, Oracle. All rights reserved.


Configuring Flashback Database Using EM

Enable flashback logging and specify the Flash Recovery Area.

12 - 12 Copyright © 2007, Oracle. All rights reserved.


Flashback Database: Examples

RMAN> FLASHBACK DATABASE TO TIME =


2> "TO_DATE('2007-05-27 16:00:00',
3> 'YYYY-MM-DD HH24:MI:SS')";

RMAN> FLASHBACK DATABASE TO SCN=23565;

RMAN> FLASHBACK DATABASE


2> TO SEQUENCE=223 THREAD=1;

SQL> FLASHBACK DATABASE


2 TO TIMESTAMP(SYSDATE-1/24);

SQL> FLASHBACK DATABASE TO SCN 53943;

SQL> FLASHBACK DATABASE TO RESTORE POINT b4_load;

12 - 13 Copyright © 2007, Oracle. All rights reserved.


Performing Flashback Database Using EM
Selecting object and operation type:

12 - 14 Copyright © 2007, Oracle. All rights reserved.


Performing Flashback Database Using EM

Launching the Recovery Wizard:

12 - 15 Copyright © 2007, Oracle. All rights reserved.


Performing Flashback Database Using EM

12 - 16 Copyright © 2007, Oracle. All rights reserved.


Excluding Tablespaces from
Flashback Database
ALTER TABLESPACE <ts_name> FLASHBACK {ON|OFF}

SQL> ALTER TABLESPACE users FLASHBACK OFF;


SQL> SELECT name, flashback_on FROM v$tablespace;

NAME FLA
------------------------------ ---
SYSTEM YES
SYSAUX YES
UNDOTBS1 YES
USERS NO
TEMP YES
EXAMPLE YES
• Take the tablespace offline before you perform the
Flashback Database recovery.
• Drop the tablespace or recover the offline files with
traditional point-in-time recovery.
12 - 17 Copyright © 2007, Oracle. All rights reserved.
Flashback Database Considerations

• When the Flashback Database operation completes, open


the database:
– In read-only mode to verify that the correct target time or SCN
was used
– With a RESETLOGS operation to allow for DML
• The opposite of “flash back” is “recover.”
• You cannot use Flashback Database in the following
situations:
– The control file has been restored or re-created.
– A tablespace has been dropped.
– A data file has been reduced in size.
• Use the TO BEFORE RESETLOGS clause to flash back to
before the last RESETLOGS operation.

12 - 18 Copyright © 2007, Oracle. All rights reserved.


Guaranteed Restore Points

A guaranteed restore point ensures that you can perform a


FLASHBACK DATABASE command to that SCN at any time.

SQL> CREATE RESTORE POINT before_upgrade


2 GUARANTEE FLASHBACK DATABASE;

12 - 19 Copyright © 2007, Oracle. All rights reserved.


Flashback Database and
Guaranteed Restore Points
To use guaranteed restore points, the database must satisfy
the following prerequisites:
• The COMPATIBLE initialization parameter must be set to
10.2 or greater.
• The database must be running in ARCHIVELOG mode.
• FLASHBACK DATABASE requires the use of archived redo
logs starting from around the time of the restore point.
• A Flash Recovery Area must be configured.

12 - 20 Copyright © 2007, Oracle. All rights reserved.


Monitoring Flashback Database

To monitor the ability to meet your retention target:


• View the Flash Recovery Area disk quota:
SQL> SELECT estimated_flashback_size,
2 flashback_size
3 FROM V$FLASHBACK_DATABASE_LOG;

• Determine the current flashback window:



SQL> SELECT oldest_flashback_scn,
2 oldest_flashback_time
3 FROM V$FLASHBACK_DATABASE_LOG;

• Monitor logging in the Flashback Database logs:


SQL> SELECT *
2 FROM V$FLASHBACK_DATABASE_STAT;

12 - 22 Copyright © 2007, Oracle. All rights reserved.


Monitoring Flashback Database with EM

12 - 24 Copyright © 2007, Oracle. All rights reserved.


Flashback Data Archive

Original
data in
buffer cache

DML operations

Background process collects and writes


original data to a Flashback Data Archive.

Historical
table data

Flashback Data Archive

12 - 25 Copyright © 2007, Oracle. All rights reserved.


Flashback Data Archive Process

1. Create the Flashback Data Archive.


2. Specify the default Flashback Data Archive.
3. Enable the Flashback Data Archive.
4. View Flashback Data Archive data.

12 - 26 Copyright © 2007, Oracle. All rights reserved.


Flashback Data Archive Scenario

Using Flashback Data Archive to access historical data:

-- create the Flashback Data Archive


CREATE FLASHBACK ARCHIVE DEFAULT fla1 1
TABLESPACE tbs1 QUOTA 10G RETENTION 5 YEAR;

-- Specify the default Flashback Data Archive


ALTER FLASHBACK ARCHIVE fla1 SET DEFAULT;
2

-- Enable Flashback Data Archive


ALTER TABLE inventory FLASHBACK ARCHIVE; 3
ALTER TABLE stock_data FLASHBACK ARCHIVE;

SELECT product_number, product_name, count FROM inventory AS OF


TIMESTAMP TO_TIMESTAMP ('2007-01-01 00:00:00', 'YYYY-MM-DD
HH24:MI:SS');

12 - 27 Copyright © 2007, Oracle. All rights reserved.


Viewing Flashback Data Archives

Viewing the results:


View Name (DBA/USER) Description

*_FLASHBACK_ARCHIVE Displays information about Flashback


Data Archives

*_FLASHBACK_ARCHIVE_TS Displays tablespaces of Flashback Data


Archives

*_FLASHBACK_ARCHIVE_TABLES Displays information about tables that are


enabled for flashback archiving

12 - 29 Copyright © 2007, Oracle. All rights reserved.


Flashback Data Archive DDL Restrictions

Using any of the following DDL statements on a table enabled


for Flashback Data Archive causes the error ORA-55610:
• ALTER TABLE statement that does any of the following:
– Drops, renames, or modifies a column
– Performs partition or subpartition operations
– Converts a LONG column to a LOB column
– Includes an UPGRADE TABLE clause, with or without an
INCLUDING DATA clause
• DROP TABLE statement
• RENAME TABLE statement
• TRUNCATE TABLE statement

12 - 30 Copyright © 2007, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Enable row movement on a table
• Perform Flashback Table operations
• Configure Flashback Database
• Perform Flashback Database operations
• Monitor Flashback Database
• Set up and use a Flashback Data Archive

12 - 31 Copyright © 2007, Oracle. All rights reserved.


Practice 12 Overview:
Working with Flashback Database
This practice covers the following topics:
• Performing Flashback Database to undo unwanted
transactions
• Monitoring the Flashback Database retention
• Determining the size of the flashback logs
• Creating a Flashback Data Archive

12 - 32 Copyright © 2007, Oracle. All rights reserved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy