Less17 Flashback Tb
Transcript of Less17 Flashback Tb
-
8/14/2019 Less17 Flashback Tb
1/30
17Copyright 2005, Oracle. All rights reserved.
Performing Flashback
-
8/14/2019 Less17 Flashback Tb
2/30
-
8/14/2019 Less17 Flashback Tb
3/30
17-3 Copyright 2005, Oracle. All rights reserved.
Flashback Technology: Benefits
The Flashback technology is a revolutionary
advance in recovery.
Traditional recovery techniques are slow:
The entire database or a file has to be restored, andnot 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 multiple-step procedures are involved.
> Overview
Database
Table
Drop
Query
Versions
Transaction
-
8/14/2019 Less17 Flashback Tb
4/30
17-4 Copyright 2005, Oracle. All rights reserved.
When to Use the Flashback Technology
TRUEUndo dataTableUpdate with the wrong
WHERE clause
Undo data
Undo data
Undo data
Recycle bin
Flashback
logs
Uses
Transaction
Version
Query
Drop
Database
Flashback
Technology
FALSECompare current data
with data from the past
FALSEInvestigate several
historical states of data
Tx
FALSECompare versions of a
row
TRUEDrop tableTable
TRUETruncate table; Undesired
multitable changes made
Database
Affects
DataScenario Examples
Object
Level
-
8/14/2019 Less17 Flashback Tb
5/30
17-5 Copyright 2005, Oracle. All rights reserved.
Flashing Back Any Error
Flashback Database brings the database to an
earlier point in time by undoing all changes made
since that time.
Flashback Table recovers a table to a point in timein the past without having to restore from a
backup.
Flashback Drop restores accidentally dropped
tables.
-
8/14/2019 Less17 Flashback Tb
6/30
17-6 Copyright 2005, 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
Thedatabase is
corrupted.
Thedatabase is
rewound.
Press therewind button.
Usersgenerate
errors.
Overview
> Database
Table
Drop
QueryVersions
Transaction
-
8/14/2019 Less17 Flashback Tb
7/3017-7 Copyright 2005, Oracle. All rights reserved.
Flashback Database:
Reducing Restore Time
Backup User errorApply logs
forward
Restore filesGenerate logs
Repaired
database
Incomplete Recovery
Backup
User
error
Apply Flashback
logs backward
Flashback logs
Repaired
database
Flashback Database
-
8/14/2019 Less17 Flashback Tb
8/3017-8 Copyright 2005, Oracle. All rights reserved.
Flashback Database: Considerations
When the Flashback Database operationcompletes, the database must be opened by usingone of these methods:
In read-only mode to verify that the correct target
time or SCN has been used
With the RESETLOGS parameter to allow for updates
The opposite of flash back is recover.
-
8/14/2019 Less17 Flashback Tb
9/3017-9 Copyright 2005, Oracle. All rights reserved.
Flashback Database: Limitations
You cannot use Flashback Database in the followingsituations:
The control file has been restored or re-created.
A tablespace has been dropped. A data file has been shrunk.
PresentFlashback
target time
Drop
tablespace
Shrink data
file
Re-create
control file
-
8/14/2019 Less17 Flashback Tb
10/3017-10 Copyright 2005, Oracle. All rights reserved.
Enabling Flashback Database
-
8/14/2019 Less17 Flashback Tb
11/3017-11 Copyright 2005, Oracle. All rights reserved.
Flashback Table: Overview
Flashback Table recovers tables to aspecific point in time.
Flashback Table is an in-place operation.
The database stays online.
UserErroneous
DMLs
Flashed back
tables
Overview
Database
> Table
Drop
QueryVersions
Transaction
-
8/14/2019 Less17 Flashback Tb
12/3017-12 Copyright 2005, 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 toperform a Flashback Table operation.
The FLASHBACKTABLE 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.
-
8/14/2019 Less17 Flashback Tb
13/30
-
8/14/2019 Less17 Flashback Tb
14/3017-14 Copyright 2005, Oracle. All rights reserved.
Performing Flashback Table
FLASHBACK TABLE hr.employees TO TIMESTAMP
TO_TIMESTAMP('2005-05-05 05:32:00',
'YYYY-MM-DD HH24:MI:SS');
-
8/14/2019 Less17 Flashback Tb
15/3017-15 Copyright 2005, Oracle. All rights reserved.
Performing Flashback Table
Notes Only Page
-
8/14/2019 Less17 Flashback Tb
16/3017-16 Copyright 2005, Oracle. All rights reserved.
Flashback Table: Considerations
The FLASHBACKTABLE command executes as a
single transaction, acquiring exclusive DML locks.
Statistics are not flashed back.
Current indexes and dependent objects aremaintained.
Flashback Table operations:
Cannot be performed on system tables
Cannot span DDL operations
Are written to the alert log file
Generate undo and redo data
-
8/14/2019 Less17 Flashback Tb
17/3017-17 Copyright 2005, Oracle. All rights reserved.
Flashback Drop: Overview
DROP TABLE employees; FLASHBACK TABLE
employees
TO BEFORE DROP;
Mistake wasmade
Recycle
Bin
Overview
Database
Table
> Drop
QueryVersions
Transaction
-
8/14/2019 Less17 Flashback Tb
18/3017-18 Copyright 2005, Oracle. All rights reserved.
Flashing Back Dropped Tables
Through Enterprise Manager
Dependent bitmap index
will also be flashed back.
-
8/14/2019 Less17 Flashback Tb
19/3017-19 Copyright 2005, Oracle. All rights reserved.
Flashback Drop: Considerations
Flashback Drop does not work for tables that:
Reside in the SYSTEMtablespace
Use fine-grained auditing or Virtual Private
Database
Reside in a dictionary managed tablespace Have been purged, either by manual purging or
automatic purging under space pressure
The following dependencies are not protected:
Bitmap-join indexes
Materialized view logs
Referential integrity constraints
Indexes dropped before tables
-
8/14/2019 Less17 Flashback Tb
20/3017-20 Copyright 2005, 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 madeby a transaction.
Tx3
Tx1
Tx2
Time
Flashback
Overview
Database
Table
Drop
> QueryVersions
Transaction
-
8/14/2019 Less17 Flashback Tb
21/3017-21 Copyright 2005, Oracle. All rights reserved.
Flashback Query: Overview
t1 t2
SELECT employee_id, salary FROM employees
AS OF TIMESTAMP t1
WHERE employee_id = 200
EmployeesEmployees Unwanted
updates
-
8/14/2019 Less17 Flashback Tb
22/3017-22 Copyright 2005, Oracle. All rights reserved.
Flashback Query: Example
11:00 11:10
UPDATE employees SET salary =
(SELECT salary FROM employees
AS OF TIMESTAMP TO_TIMESTAMP
('2005-05-0411:00:00','yyyy-mm-ddhh24:mi:ss')
WHERE employee_id = 200)
WHERE employee_id = 200
EmployeesEmployees
salary = 4400
Employees
salary = 4400salary = 4840
-
8/14/2019 Less17 Flashback Tb
23/30
-
8/14/2019 Less17 Flashback Tb
24/3017-24 Copyright 2005, Oracle. All rights reserved.
Flashback Versions Query Through
Enterprise Manager
-
8/14/2019 Less17 Flashback Tb
25/30
17-25 Copyright 2005, Oracle. All rights reserved.
Flashback Versions Query: Considerations
TheVERSIONS clause cannot be used to query:
External tables
Temporary tables
Fixed tables Views
TheVERSIONS clause cannot span DDL
commands.
Segment shrink operations are filtered out.
-
8/14/2019 Less17 Flashback Tb
26/30
17-26 Copyright 2005, Oracle. All rights reserved.
Flashback Transaction Query:
Overview
Undo
SQL
FLASHBACK_TRANSACTION_QUERY
DBA
User
Erroneous
DML
Overview
Database
Table
Drop
QueryVersions
> Transaction
-
8/14/2019 Less17 Flashback Tb
27/30
17-27 Copyright 2005, Oracle. All rights reserved.
Flashback Transaction Query Through
Enterprise Manager
-
8/14/2019 Less17 Flashback Tb
28/30
17-28 Copyright 2005, 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.
-
8/14/2019 Less17 Flashback Tb
29/30
17-29 Copyright 2005, Oracle. All rights reserved.
Summary
In this lesson, you should have learned how to:
Describe Flashback Database
Restore the table content to a specific point in the
past with Flashback Table Recover from a dropped table
View the contents of the database as of any single
point in time with Flashback Query
See versions of a row over time with Flashback
Versions Query
View transaction history or a row with Flashback
Transaction Query
-
8/14/2019 Less17 Flashback Tb
30/30
Practice Overview:
Using Flashback
This practice covers the following topics:
Using Flashback to recover a dropped table
Performing Flashback Versions Query