Presentation is loading. Please wait.

Presentation is loading. Please wait.

23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback.

Similar presentations


Presentation on theme: "23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback."— Presentation transcript:

1 23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback

2 23-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to: Describe Flashback Database Recover from a dropped table Describe Flashback Versions Query to recover from user errors Describe Flashback Transaction Query to perform transaction level recovery Use the Flashback Table to restore the table content to a specific point in the past

3 23-3 Copyright © 2004, Oracle. All rights reserved. Flashback Technology: Benefits Flashback technology is a revolutionary advance in recovery. Traditional recovery techniques are slow. –Entire a database or a file has to be restored, not just the incorrect data. –Every change in the database log must be examined. Flashback is fast. –Changes are indexed by row and by transaction. –Only the changed data is restored. Flashback commands are easy. –No complex multi-step procedures

4 23-4 Copyright © 2004, Oracle. All rights reserved. When to Use the Flashback Technology Object Level ScenarioFlashback Technology DatabaseDrop userFlashback Database Truncate tableFlashback Database Batch job: partial changesFlashback Database TableDrop tableFlashback Drop Update with wrong WHERE clause Flashback Table Comparing current data against the data at some time in the past Flashback Query TxBatch job runs twice, but not really sure of the objects affected Flashback Transaction

5 23-5 Copyright © 2004, Oracle. All rights reserved. Flash Back Any Error Flashback Database brings the database to a prior point in time by undoing all changes made since that time. Flashback Table recovers a table to a point in time in the past without restoring a backup. Flashback Drop restores accidentally dropped tables.

6 23-6 Copyright © 2004, Oracle. All rights reserved. Flashback Database: Overview The Flashback Database operation: Works like a rewind button for the database Can be used in cases of logical data corruptions made by users. Database is corrupted. Database is "rewound." Press the rewind button. Users generate errors.

7 23-7 Copyright © 2004, Oracle. All rights reserved. Flashback Database: Reducing Restore Time Backup User error Apply logs forward Restore files Generate logs Repaired database Incomplete Recovery Backup User error Apply Flashback logs backward Flashback logs Repaired database Flashback Database

8 23-8 Copyright © 2004, 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 updates The opposite of flashback 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 shrunk. –You want to flash back before the RESETLOGS operation.

9 23-9 Copyright © 2004, Oracle. All rights reserved. Flashback Drop: An Overview DROP TABLE employees; FLASHBACK TABLE employees TO BEFORE DROP; Mistake was made

10 23-10 Copyright © 2004, Oracle. All rights reserved. Flash Back Dropped Tables Using EM

11 23-11 Copyright © 2004, Oracle. All rights reserved. Querying the Recycle Bin SELECT owner, original_name, object_name, type, ts_name, droptime, related, space FROM dba_recyclebin WHERE can_undrop = 'YES'; SELECT original_name, object_name, type, ts_name, droptime, related, space FROM user_recyclebin WHERE can_undrop = 'YES'; SQL> SHOW RECYCLEBIN

12 23-12 Copyright © 2004, Oracle. All rights reserved. Restoring Objects from the Recycle Bin Use the FLASHBACK TABLE … command to restore dropped tables and dependent objects. If multiple recycle bin entries have the same original name: –Use unique system-generated names to restore a particular version –When using original names, restored table is LIFO Rename the original name if that name is currently used. FLASHBACK TABLE TO BEFORE DROP [RENAME TO ]

13 23-13 Copyright © 2004, Oracle. All rights reserved. Bypassing the Recycle Bin DROP TABLESPACE [INCLUDING CONTENTS] ; DROP USER [CASCADE] ; DROP TABLE [PURGE] ;

14 23-14 Copyright © 2004, Oracle. All rights reserved. Flashback Drop: Considerations Protected tables: –Are non- SYSTEM tablespace tables –Are stored in locally managed tablespaces –Do not use fine-grained auditing or Virtual Private Database The following dependencies are not protected: –Bitmap-join indexes –Materialized view logs –Referential integrity constraints –Indexes dropped before tables Purged tables cannot be flashed back.

15 23-15 Copyright © 2004, Oracle. All rights reserved. Where Are We? Flashback Database Flashback Drop Flashback Versions Query Flashback Transaction Query Flashback Table

16 23-16 Copyright © 2004, Oracle. All rights reserved. Flashback Time Navigation Flashback Query –Query all data at a specified point in time. Flashback Versions Query –See all versions of a row between two times. –See the transactions that changed the row. Flashback Transaction Query –See all changes made by a transaction. Tx3 Tx1 Tx2 Time Flashback

17 23-17 Copyright © 2004, Oracle. All rights reserved. Flashback Versions Query: Overview t1t2 Tx1Tx1Tx2Tx2 SELECT versions_xid, salary FROM employees VERSIONS BETWEEN TIMESTAMP t1 and t2 WHERE last_name = ‘Higgins'; Tx0Tx0 Tx0Tx0Tx1Tx1Tx2Tx2 Employees Higgins

18 23-18 Copyright © 2004, Oracle. All rights reserved. Flashback Versions Query Using EM

19 23-19 Copyright © 2004, Oracle. All rights reserved. Flashback Versions Query: Considerations The VERSIONS clause cannot be used to query: –External tables –Temporary tables –Fixed tables –Views The VERSIONS clause cannot span DDL commands. Segment shrink operations are filtered out.

20 23-20 Copyright © 2004, Oracle. All rights reserved. Flashback Transaction Query: Overview Undo SQL FLASHBACK_TRANSACTION_QUERY DBA USER Erroneous DML

21 23-21 Copyright © 2004, Oracle. All rights reserved. Flashback Transaction Query Using EM

22 23-22 Copyright © 2004, Oracle. All rights reserved. Flashback Transaction Query: Considerations DDLs are seen as dictionary updates. Dropped objects appear as object numbers. Dropped users appear as user identifiers. Minimal supplemental logging may be needed: ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

23 23-23 Copyright © 2004, Oracle. All rights reserved. Where Are We? Flashback Database Flashback Drop Flashback Versions Query Flashback Transaction Query Flashback Table

24 23-24 Copyright © 2004, Oracle. All rights reserved. Flashback Table: Overview Recover tables to a specific point in time. Flashback Table is an in-place operation. Database stays online. User Erroneous DMLs Flashed back tables

25 23-25 Copyright © 2004, 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. The FLASHBACK TABLE privilege is required to perform flashback of a table. Row movement must be enabled on the table that you are performing the flashback operation on.

26 23-26 Copyright © 2004, Oracle. All rights reserved. Enabling Row Movement on a Table

27 23-27 Copyright © 2004, Oracle. All rights reserved. Performing Flashback Table

28 23-28 Copyright © 2004, 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 –Are written to the alert log file

29 23-29 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Describe Flashback Database Recover from a dropped table Describe Flashback Versions Query to recover from user errors Describe Flashback Transaction Query to perform transaction level recovery Use the Flashback Table to restore the table content to a specific point in the past

30 23-30 Copyright © 2004, Oracle. All rights reserved. Practice Overview: Using Flashback This practice covers the following topics: Using Flashback to recover a dropped table Performing Flashback Versions Query


Download ppt "23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback."

Similar presentations


Ads by Google