11 Copyright © 2007, Oracle. All rights reserved. Using Flashback Technology.

Slides:



Advertisements
Similar presentations
Data Definition Language (DDL)
Advertisements

18 Copyright © Oracle Corporation, All rights reserved. Transporting Data Between Databases.
4 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
17 Copyright © 2005, Oracle. All rights reserved. Performing Flashback.
9 Copyright © 2004, Oracle. All rights reserved. Managing Data.
Basic Storage Concepts and Settings
9 Copyright © 2009, Oracle. All rights reserved. Managing Data Concurrency.
10 Copyright © 2009, Oracle. All rights reserved. Managing Undo Data.
5 Copyright © 2006, Oracle. All rights reserved. Database Recovery.
2 Copyright © 2004, Oracle. All rights reserved. Creating Stored Functions.
7 Copyright © 2006, Oracle. All rights reserved. Dealing with Database Corruption.
Chapter 6 Additional Database Objects
1 Oracle Database 11g – Flashback Data Archive. 2 Data History and Retention Data retention and change control requirements are growing Regulatory oversight.
Preface 1 Introduction Course Objectives 1-2 How DBAs Spend Their Time 1-3 Oracle Database 10g Manageability Goals 1-4 Database Management Challenges 1-5.
IS 221: DATABASE ADMINISTRATION Lecture 6:Create Users & Manage Users. Information Systems Department 1.
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
9 Copyright © 2007, Oracle. All rights reserved. Managing Data and Concurrency.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
16 Copyright © 2004, Oracle. All rights reserved. Undo Management.
7 Copyright © 2004, Oracle. All rights reserved. Recovering from Noncritical Losses.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
6 Copyright © 2006, Oracle. All rights reserved. Flashback.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
8 Copyright © 2005, Oracle. All rights reserved. Managing Data.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
11 Copyright © 2004, Oracle. All rights reserved. Dealing with Database Corruption.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
Week 3 Lecture 2 Basic Storage Concepts and Settings.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
10 Copyright © 2004, Oracle. All rights reserved. Recovering from User Errors.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
13 Copyright © Oracle Corporation, All rights reserved. Maintaining Data Integrity.
Over view  Why Oracle Forensic  California Breach security Act  Oracle Logical Structure  Oracle System Change Number  Oracle Data Block Structure.
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
© 2006 Northgate Information Solutions plc and its associated companies. All rights reserved. Slide 1.
12 Copyright © Oracle Corporation, All rights reserved. User-Managed Complete Recovery.
18 Copyright © 2004, Oracle. All rights reserved. Backup and Recovery Concepts.
20 Copyright © 2008, Oracle. All rights reserved. Cache Management.
6 Copyright © 2007, Oracle. All rights reserved. Performing User-Managed Backup and Recovery.
3 Copyright © 2007, Oracle. All rights reserved. Using the RMAN Recovery Catalog.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
13 Copyright © 2007, Oracle. All rights reserved. Using the Data Recovery Advisor.
20 Copyright © 2006, Oracle. All rights reserved. Best Practices and Operational Considerations.
11 Copyright © 2004, Oracle. All rights reserved. Performing a Migration Using Oracle Migration Workbench (Part II)
What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived.
6 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
7 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.
8 Copyright © Oracle Corporation, All rights reserved. Managing Tablespaces and Data files.
23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
9 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
10 Copyright © 2007, Oracle. All rights reserved. Managing Undo Data.
Managing Privileges.
Performing Flashback.
Recovering from User Errors
Performing Tablespace Point-in-Time Recovery
Using Flashback Technology II
Using Flashback Technology I
Managing Privileges.
Presentation transcript:

11 Copyright © 2007, Oracle. All rights reserved. Using Flashback Technology

Copyright © 2007, Oracle. All rights reserved Objectives After completing this lesson, you should be able to: Query the recycle bin Restore dropped tables from the recycle bin Perform Flashback Query Use Flashback Version Query Use Flashback Transaction Query Use Flashback Transaction

Copyright © 2007, Oracle. All rights reserved Flashback Technology Object Level Scenario ExamplesFlashback Technology Depends On Affects Data DatabaseTruncate table; Undesired multitable changes made DatabaseFlashback logs TRUE TableDrop tableDropRecycle binTRUE Update with the wrong WHERE clause TableUndo dataTRUE Compare current data with data from the past QueryUndo dataFALSE Compare versions of a row VersionUndo dataFALSE Keep historical transaction data Data ArchiveUndo dataTRUE TransactionInvestigate and back out suspect transactions TransactionUndo dataTRUE

Copyright © 2007, Oracle. All rights reserved Transactions and Undo Undo “old” data in undo tablespace DML operations Original data in buffer cache

Copyright © 2007, Oracle. All rights reserved Guaranteeing Undo Retention A transaction that generates more undo than what there is space for will fail. SELECT statements running 15 minutes or less are always satisfied. Undo data in undo tablespace Retention guarantee: 15 minutes

Copyright © 2007, Oracle. All rights reserved Preparing Your Database for Flashback Creating an undo tablespace Enabling Automatic Undo Management Specifying versus guaranteeing undo retention Default database initialization parameters: — UNDO_MANAGEMENT='AUTO' — UNDO_TABLESPACE='UNDOTBS1' — UNDO_RETENTION=900

Copyright © 2007, Oracle. All rights reserved Preparing Your Database for Flashback Full Notes Page

Copyright © 2007, Oracle. All rights reserved Flashback Drop and the Recycle Bin DROP TABLE employees; FLASHBACK TABLE employees TO BEFORE DROP; Mistake was made. RECYCLEBIN=ON

Copyright © 2007, Oracle. All rights reserved Recycle Bin DROP TABLE employees; BIN$zbjra9wy==$0EMPLOYEES_PK EMPLOYEES Recycle bin DBA_FREE_SPACE BIN$zbjrBdpw==$0 USER_OBJECTS BIN$zbjrBdpw==$0 EMPLOYEES BIN$zbjra9wy==$0 EMPLOYEES_PK 4 Objects are: – Renamed – Not moved

Copyright © 2007, Oracle. All rights reserved Recycle Bin Full Notes Page

Copyright © 2007, Oracle. All rights reserved Restoring Tables from the Recycle Bin 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, the restored table is last in, first out (LIFO) Rename the original name if that name is currently used. FLASHBACK TABLE TO BEFORE DROP [RENAME TO ];

Copyright © 2007, Oracle. All rights reserved Recycle Bin: Automatic Space Reclamation BIN$zbjrBdpw==$0 BIN$zbjra9wy==$0 BIN$zbjra9wy==$0 BIN$zbjrBdpw==$ Recycle bin DBA_FREE_SPACE - RECYCLEBIN Autoextend

Copyright © 2007, Oracle. All rights reserved Recycle Bin: Manual Space Reclamation PURGE {TABLE |INDEX } PURGE TABLESPACE [USER ] PURGE [USER_|DBA_]RECYCLEBIN

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

Copyright © 2007, 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'; SQL> SELECT original_name, object_name, ts_name, droptime FROM user_recyclebin WHERE can_undrop = 'YES'; 2 ORIGINAL_NAME OBJECT_NAME TS_NAM DROPTIME EMPLOYEES2 BIN$NE4Rk64w...gbpQ==$0 USERS :15:45:13 SQL> SHOW RECYCLEBIN

Copyright © 2007, Oracle. All rights reserved Querying Data from Dropped Tables SELECT... FROM "BIN$zbjrBdpw==$0" [AS OF...] WHERE... Recycle bin DBA_INDEXES YES INDEX_NAMEDROPPED NOSALES_PK DBA_TABLES TABLE_NAMEDROPPED YES NOSALES BIN$zbjrBdpw==$0 EMPLOYEES BIN$zbjra9wy==$0 EMPLOYEES_PK

Copyright © 2007, Oracle. All rights reserved Using Flashback Technology to Query Data Flashback Query –Query all data at a specified point in time. Flashback Version 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

Copyright © 2007, Oracle. All rights reserved Flashback Query T1 T2 SELECT employee_id, salary FROM employees AS OF TIMESTAMP WHERE employee_id = 200 employees Unwanted updates Use to query all data at a specified point in time.

Copyright © 2007, Oracle. All rights reserved Flashback Query: Example 11:0011:10 UPDATE employees SET salary = (SELECT salary FROM employees AS OF TIMESTAMP TO_TIMESTAMP (' :00:00', 'yyyy-mm-dd hh24:mi:ss') WHERE employee_id = 200) WHERE employee_id = 200 employees salary = 4,400 employees salary = 4,400 salary = 4,840

Copyright © 2007, Oracle. All rights reserved Flashback Version Query t1 t2 Tx1Tx1Tx2Tx2 SELECT versions_xid, salary FROM employees VERSIONS BETWEEN TIMESTAMP and WHERE employee_id = 200; Tx0Tx0 Tx0Tx0Tx1Tx1Tx2Tx2 employees 200

Copyright © 2007, Oracle. All rights reserved Using Enterprise Manager to Perform Flashback Version Query

Copyright © 2007, Oracle. All rights reserved Flashback Version 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.

Copyright © 2007, Oracle. All rights reserved Flashback Transaction Query Undo SQL FLASHBACK_TRANSACTION_QUERY DBA User Erroneous DML

Copyright © 2007, Oracle. All rights reserved Using Enterprise Manager to Perform Flashback Transaction Query

Copyright © 2007, Oracle. All rights reserved Flashback Transaction Query: Considerations DDL commands are seen as dictionary updates. Flashback Transaction Query on a transaction underlying a DDL command displays the data dictionary changes. Dropped objects appear as object numbers. Dropped users appear as user identifiers.

Copyright © 2007, Oracle. All rights reserved Flashback Transaction Setting up Flashback Transaction prerequisites Stepping through a possible workflow Using the Flashback Transaction Wizard Querying transactions with and without dependencies Choosing back-out options and flashing back transactions Reviewing the results

Copyright © 2007, Oracle. All rights reserved Prerequisites

Copyright © 2007, Oracle. All rights reserved Flashing Back a Transaction You can flash back a transaction with Enterprise Manager or from the command line. EM uses the Flashback Transaction Wizard, which calls the DBMS_FLASHBACK.TRANSACTION_BACKOUT procedure with the NOCASCADE option. If the PL/SQL call finishes successfully, it means that the transaction does not have any dependencies and a single transaction is backed out successfully.

Copyright © 2007, Oracle. All rights reserved Possible Workflow 1.Viewing data in a table 2.Discovering a logical problem 3.Using Flashback Transaction 1.Performing a query 2.Selecting a transaction 3.Flashing back a transaction (with no conflicts) 4.Choosing other back-out options (if conflicts exists) 4.Reviewing Flashback Transaction results

Copyright © 2007, Oracle. All rights reserved Viewing Data

Copyright © 2007, Oracle. All rights reserved Flashback Transaction Wizard

Copyright © 2007, Oracle. All rights reserved Flashback Transaction Wizard

Copyright © 2007, Oracle. All rights reserved Flashback Transaction Wizard 2 1

Copyright © 2007, Oracle. All rights reserved Flashback Transaction Wizard

Copyright © 2007, Oracle. All rights reserved Choosing Other Back-out Options

Copyright © 2007, Oracle. All rights reserved Choosing Other Back-out Options

Copyright © 2007, Oracle. All rights reserved Final Steps Without EM After choosing your back-out option, the dependency report is generated in the DBA_FLASHBACK_TXN_STATE and DBA_FLASHBACK_TXN_REPORT tables. Review the dependency report that shows all transactions which were backed out. Commit the changes to make them permanent. Roll back to discard the changes.

Copyright © 2007, Oracle. All rights reserved Summary In this lesson, you should have learned how to: Query the recycle bin Restore dropped tables from the recycle bin Perform Flashback Query Use Flashback Version Query Use Flashback Transaction Query Use Flashback Transaction

Copyright © 2007, Oracle. All rights reserved Practice 11 Overview: Performing Flashback Database This practice covers the following topics: Recycle bin activities Flashback Query Flashback Transaction

Copyright © 2007, Oracle. All rights reserved