Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived.

Similar presentations


Presentation on theme: "What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived."— Presentation transcript:

1 What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived log files Backups Retrieves old data block versions Integrated with RMAN and SQL*Plus.

2 Oracle Flashback Technology Options Oracle Flashback Query Oracle Flashback Transaction Query Oracle Flashback Table Oracle Flashback Drop Oracle Flashback Version Query

3 FLASHBACK TABLE Summary Point-in-time Recovery On-line Table Attributes Maintained Constraints Considered Return to Original State

4 FLASHBACK in Practice Prerequisites FLASHBACK ANY TABLE system privilege or FLASHBACK object privilege on table SELECT, INSERT, DELETE and ALTER privilege on table UNDO goes back to desired point in time Execute SQL*Plus command FLASHBACK TABLE SCOTT.ORDERS TO TIMESTAMP TO_DATE('28-JUL-08 01:00:00','dd-MON-yy hh24:mi:ss');

5 Manage the Recycle Bin Recycle Bin: Data dictionary table Stores information about dropped tables, nested tables, constraints, indexes and related objects Information stays in recycle bin until purged

6 Viewing Contents of Recycle Bin At the view level: DBA_RECYCLEBIN view USER_RECYCLEBIN view Using SQL*Plus : SQL> SHOW RECYCLEBIN

7 Object Naming in the Recycle Bin Naming convention: BIN$unique_id$version where: unique_id is a 26-character unique identifier version is a system-assigned version number

8 The FLASHBACK TABLE... TO BEFORE DROP Statement Used to recover objects from the recycle bin Must have the same privileges you needed to drop the table in order to execute the command May use the system-assigned name, the name you have assigned to the table using the RENAME TO clause, or the original name of the table Dependent objects keep the names the system has assigned to them

9 Purging Objects in the Recycle Bin Permanently delete data from recycle bin Syntax: PURGE RECYCLEBIN; PURGE DBA_RECYCLEBIN;

10 Automatically Purged Objects Objects belonging to a dropped user Dependent objects belonging to dropped types Member tables belonging to a dropped cluster Objects belonging to a dropped tablespace

11 Disabling the Recycle Bin Disabling does not purge the recycle bin You may not recover dropped tables from a disabled recycle bin Syntax: ALTER SESSION SET recyclebin = OFF; ALTER SYSTEM SET recyclebin = OFF;

12 Enabling the Recycle Bin The recycle bin is enabled by default. Use ALTER SESSION SET or ALTER SYSTEM SET to enable it, if needed: ALTER SESSION SET recyclebin = ON; ALTER SYSTEM SET recyclebin = ON;

13 Recover from User Errors Using Flashback Versions Query Use VERSIONS BETWEEN clause of the SELECT statement for Flashback Versions Queries: SELECT … VERSIONS {BETWEEN {SCN | TIMESTAMP} start AND end}

14 Perform Transaction Level Recovery Using Flashback Transaction Query Query against FLASHBACK_TRANSACTION_QUERY view Requires SELECT ANY TRANSACTION system privilege Gives you information that lets you undo changes made by the transaction Lets you reconstruct SQL statements used to make changes to the database This feature is useful for recovering from application or user errors.

15 Flashback Transaction Query Example SET PAGESIZE 130 SET LINESIZE 110 TTITLE 'Current FLASHBACK_TRANSACTION_QUERY Contents For Selected Users' COL xid FORMAT A16 HEADING 'XID#' COL commit_scn FORMAT 99999999 HEADING 'Commit|SCN' COL operation FORMAT A10 HEADING 'Operation' COL logon_user FORMAT A06 HEADING 'User|Logon ID' COL table_owner FORMAT A06 HEADING 'Table|Owner' COL table_name FORMAT A12 HEADING 'Table Name' COL undo_sql FORMAT A80 HEADING 'UNDO SQL'

16 Flashback Transaction Query Example SELECT xid, operation, logon_user, table_owner, table_name, commit_scn, undo_sql FROM flashback_transaction_query WHERE xid IN (SELECT versions_xid FROM hr.users VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE WHERE user_id >= 540 AND versions_xid IS NOT NULL);

17 Flashback Transaction Query Results Current FLASHBACK_TRANSACTION_QUERY Contents For Selected Users User Table Commit XID# Operation Logon Owner Table Name SCN ---- ----- ----- ---- ----- ------ ------ UNDO SQL ——————--------------------------------------- 04000C00E7000000 UPDATE SYS HR USERS 2150749 update "HR"."USERS" set "SALARY" = '49680' where ROWID = 'AAAGMsAAEAAAABWAAA'; 04000C00E7000000 UPDATE SYS HR USERS 2150749 update "HR"."USERS" set "SALARY" = '54900' where ROWID = 'AAAGMsAAEAAAABYAAE'; 04000C00E7000000 UPDATE SYS HR USERS 2150749 update "HR"."USERS" set "SALARY" = '32700' where ROWID = 'AAAGMsAAEAAAABYAAD';


Download ppt "What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived."

Similar presentations


Ads by Google