KDDOUG_0719071 Oracle10g: Behind the Scenes of Flashback Technologies DOUG Meeting July 19, 2007 Kirtikumar Deshpande.

Slides:



Advertisements
Similar presentations
SQL Gone Bad What to do when faulty SQL code corrupts your database Mary Louise Powers Tom Smull Lehigh University.
Advertisements

Refreshing Materialized Views
CHAPTER 4 Tablespaces and Datafiles. Introduction After installing the binaries, creating a database, and configuring your environment, the next logical.
Introduction to SQL Tuning Brown Bag Three essential concepts.
9 Copyright © 2006, Oracle. All rights reserved. Automatic Performance Management.
An Overview of GoldenGate Replication Brian Keating December 31, 2009.
A Guide to Oracle9i1 Creating and Modifying Database Tables Chapter 2.
11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Chris Ruel * Image used without permission.
SQL2-ch2 管理綱要物件.
Go-Faster Consultancy Ltd.1 Experiences of Global Temporary Tables in Oracle 8.1 David Kurtz Go-Faster Consultancy Ltd.
Data Definition Language (DDL)
Oracle Academy Egypt Virtual training week 8 Sections from 7 to 9.
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
1 Oracle 11g Results Cache Dean Richards Senior DBA, Confio Software.
Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23, 03-46,
Materialized Views.
17 Copyright © 2005, Oracle. All rights reserved. Performing Flashback.
Backup and recovery Basics of Backup and restoration Types of recovery Defining strategy Starting up and shutting down 80/20 rule SLA’s.
System Administration Accounts privileges, users and roles
Harvard University Oracle Database Administration Session 2 System Level.
10 Copyright © 2009, Oracle. All rights reserved. Managing Undo Data.
RMAN Restore and Recovery
Backup and Recovery Part 1.
Chapter 12 Performing Incomplete Recovery. Background Viewed as one of the more difficult chapters to write Thought it was important to put in material.
CHAPTER 16 User-Managed Backup and Recovery. Introduction to User Managed Backup and Recovery Backup and recover is one of the most critical skills a.
NoCOUG 2005 Winter Conference NoCOUG 2005 Winter Conference Oracle 10g Backup and Recovery New Features Daniel T. Liu Senior Technical Consultant First.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Chapter 6 Additional Database Objects
Database Technical Session By: Prof. Adarsh Patel.
1 Oracle Database 11g – Flashback Data Archive. 2 Data History and Retention Data retention and change control requirements are growing Regulatory oversight.
1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
Flashback Flashback Query Fb0.sql 9iR1 – primitive
Chapter 6 Additional Database Objects Oracle 10g: SQL.
Oracle Database 10 g Time Navigation: Human-Error Correction Magnus Lubeck DBA/Systems Analyst CERN, IT-DB Group Session id: Tammy Bednar Sr. Product.
AUSOUG National Conference Series 2009 Time Travel Back To The Future With Oracle 11g Total Recall Gavin Soorma Senior Oracle DBA, Bankwest.
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.
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.
10 Copyright © 2004, Oracle. All rights reserved. Recovering from User Errors.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Over view  Why Oracle Forensic  California Breach security Act  Oracle Logical Structure  Oracle System Change Number  Oracle Data Block Structure.
Chapter 12 Additional Database Objects. Chapter Objectives  Define the purpose of a sequence and state how it can be used by an organization  Explain.
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.
18 Copyright © 2004, Oracle. All rights reserved. Backup and Recovery Concepts.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
11 Copyright © 2007, Oracle. All rights reserved. Using Flashback Technology.
1 11g NEW FEATURES ByVIJAY. 2 AGENDA  RESULT CACHE  INVISIBLE INDEXES  READ ONLY TABLES  DDL WAIT OPTION  ADDING COLUMN TO A TABLE WITH DEFAULT VALUE.
SQL Triggers, Functions & Stored Procedures Programming Operations.
 CONACT UC:  Magnific training   
20 Copyright © 2006, Oracle. All rights reserved. Best Practices and Operational Considerations.
What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
What is Flashback? Technology that allows you to revert the database to a point in time in the past Several versions of flashback available Different types.
23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
Data, Space and Transaction Processing
Performing Flashback.
Recovering from User Errors
Performing Tablespace Point-in-Time Recovery
Using Flashback Technology II
Using Flashback Technology I
Index Index.
Presentation transcript:

KDDOUG_ Oracle10g: Behind the Scenes of Flashback Technologies DOUG Meeting July 19, 2007 Kirtikumar Deshpande

KDDOUG_ About Me Senior Oracle DBA Idearc Media Phone Directories Publication

KDDOUG_ Agenda Flashback Query - Background Oracle10g - Whats New Flashback Table Flashback Drop Table Flashback Version Query Flashback Transaction Query Flashback Database Q & A

KDDOUG_ Flashback Query - Background Oracle9i Release 1 Undo Tablespace Automatic Undo Segments Undo Retention Time Session level Flashback Query feature Oracle9i Release 2 Statement level Flashback Query feature

KDDOUG_ Whats New in Oracle10g Guaranteed Undo Retention Undo preserved for specified retention time Auto Undo Retention Tuning Undo Retention time adjusted automatically V$UNDOSTAT view enhancements New information to track long running queries

KDDOUG_ Whats New in Oracle10g Pseudocolumns ORA_ROWSCN VERSIONS_STARTTIME VERSIONS_STARTSCN VERSIONS_ENDTIME VERSIONS_ENDSCN VERISONS_XID VERSIONS_OPERATION

KDDOUG_ Whats New in Oracle10g Functions SCN_TO_TIMESTAMP TIMESTAMP_TO_SCN View FLASHBACK_TRANSACTION_QUERY Recycle Bin To restore dropped table (not PURGED)

KDDOUG_ Whats New in Oracle10g Flashback Drop Restore dropped table Flashback Table Restore table to a point in time in the past

KDDOUG_ Whats New in Oracle10g Flashback Versions Query How data changed over a timeframe Flashback Transaction Query How data changed at transactions level

KDDOUG_ Whats New in Oracle10g Flashback Database Restores database to a point in time in the past Does not use undo segments and recyclebin Needs special configuration

KDDOUG_ Guaranteed Undo Retention Guaranteed Retention makes sure that the committed undo is preserved for the specified retention time. Transactions that need more undo space may terminate due to lack of undo space as Oracle will not overwrite undo information.

KDDOUG_ Guaranteed Undo Retention UNDO Tablespace Option create unto tablespace undo_tbs datafile /u09/oradata/ked9_undo_01.dbf size 100M retention guarantee; alter tablespace undo_tbs retention guarantee; alter tablespace undo_tbs retention noguarantee; RETENTION NOGUARANTEE - Default

KDDOUG_ Auto Undo Retention Tuning UNDO_RETENTION value may change V$UNDOSTAT tracks undo retention value for sampled intervals TUNED_UNDORETENTION

KDDOUG_ V$UNDOSTAT View New Columns MAXQUERYID ACTIVEBLKS UNEXPIREDBLKS EXPIREDBLKS TUNED_UNDORETENTION

KDDOUG_ V$UNDOSTAT Example BEGIN_TIME END_TIME MAXQUERYID MAXQL TUNEDRET ACTBLK UNXPBLK XPBLK FEB-06 23:54:49 23-FEB-06 00:04: FEB-06 23:44:49 22-FEB-06 23:54: FEB-06 23:34:49 22-FEB-06 23:44:49 b1z64uk2y5p6v FEB-06 23:24:49 22-FEB-06 23:34:49 b1z64uk2y5p6v FEB-06 23:14:49 22-FEB-06 23:24:49 b1z64uk2y5p6v FEB-06 23:04:49 22-FEB-06 23:14:49 b1z64uk2y5p6v FEB-06 22:54:49 22-FEB-06 23:04:49 b1z64uk2y5p6v FEB-06 22:44:49 22-FEB-06 22:54:49 b1z64uk2y5p6v FEB-06 22:34:49 22-FEB-06 22:44:49 b1z64uk2y5p6v FEB-06 22:24:49 22-FEB-06 22:34:49 b1z64uk2y5p6v FEB-06 22:14:49 22-FEB-06 22:24:49 b1z64uk2y5p6v FEB-06 22:04:49 22-FEB-06 22:14:49 b1z64uk2y5p6v FEB-06 21:54:49 22-FEB-06 22:04:49 5rv0j37z1ztgm FEB-06 21:44:49 22-FEB-06 21:54:49 ac20brc1kdgdx FEB-06 21:34:49 22-FEB-06 21:44:49 ac20brc1kdgdx

KDDOUG_ Flashback Table Recovers table data to point in time in the past Uses undo segments to reconstruct past data Undo information must be available in undo segments Uses an internal global temporary table, SYS_TEMP_FBT, to stage data

KDDOUG_ Flashback Table Enable row movement alter table t1 enable row movement; Flashback Table to SCN or Timestamp flashback table t1 to ; flashback table t1 to timestamp( );

KDDOUG_ Flashback Table Example: SQL> select department_id, department_name from dept; DEPARTMENT_ID DEPARTMENT_NAME Administration 20 Marketing 30 Purchasing 40 Human Resources

KDDOUG_ Flashback Table SQL> delete dept; 4 rows deleted. SQL> commit; Commit complete. SQL> flashback table dept to timestamp (systimestamp - interval 10' minute); Flashback complete. SQL> select department_id, department_name from dept; DEPARTMENT_ID DEPARTMENT_NAME Administration 20 Marketing 30 Purchasing 40 Human Resources

KDDOUG_ Flashback Table Restrictions and Limitations Does not work for Clustered tables Tables in Materialized View Advance Queuing Tables Data Dictionary Tables Table Partitions/Sub-Partitions Nested Tables Remote Tables

KDDOUG_ Flashback Table Restrictions and Limitations Referential Integrity Constraints may limit flashback operation Any DDL operation on table will restrict flashback time (or SCN) to the DDL time Bug: Unpublished Internal GTT SYS_TEMP_FBT not dropped after flashback operation

KDDOUG_ Flashback Drop Table Really an undrop Table operation Does not use Undo Segments Uses RECYCLEBIN to restore a dropped table flashback table t1 to before drop; flashback table t1 to before drop rename t2;

KDDOUG_ Flashback Drop Table DROP TABLE with PURGE option, or purging RECYCLEBIN will NOT restore the table Restored dependent objects (triggers, indexes, constraints) will get system generated names Need to RENAME those explicitly

KDDOUG_ Flashback Drop Table Recyclebin Dropped objects do not release disk space Views USER_RECYCLEBIN DBA_RECYCLEBIN Public Synonym RECYCLEBIN

KDDOUG_ Flashback Drop Table Recyclebin Enabled by Default Can be Disabled 10g R1 alter system set _recyclebin = false; 10g R2 alter session set recyclebin = off; alter system set recyclebin = off;

KDDOUG_ Flashback Drop Table Example: SQL> drop table fdt cascade constraints; Table dropped. SQL> select object_name, original_name, type from recyclebin; OBJECT_NAME ORIGINAL_NAME TYPE BIN$2NkxhR9EQYaOi6iEb5MyEw==$0 FDT_I1 INDEX BIN$eH23RoJUSg6P6x98+kvK/w==$0 FDT_PK INDEX BIN$3jL+fbUZTza4Z0HRlZMYvA==$0 FDT_T1 TRIGGER BIN$2EIiiDRWQ8u/P1c366iICg==$0 FDT TABLE 4 rows selected.

KDDOUG_ Flashback Drop Table SQL> flashback table fdt to before drop; Flashback complete. SQL> select index_name obj_name, NDX' type from user_indexes where table_name ='FDT 2 union 3 select trigger_name obj_name, 'TRIG' type from user_triggers where table_name = 'FDT' 4 union 5 select constraint_name obj_name, 'CNSTR- ' ||constraint_type 6 from user_constraints where table_name = 'FDT' 7 / OBJ_NAME TYPE BIN$2NkxhR9EQYaOi6iEb5MyEw==$0 NDX BIN$3jL+fbUZTza4Z0HRlZMYvA==$0 TRIG BIN$ZsANcV+8TfGmDzwH5wzIFg==$0 CNSTR- P BIN$eH23RoJUSg6P6x98+kvK/w==$0 NDX BIN$s10Y+0xMTriID+82Iqovxg==$0 CNSTR- C 5 rows selected.

KDDOUG_ Flashback Drop Table Limitations (Does not Work For) External Tables Materialized Views Tables in Dictionary Managed Tablespaces Tables in SYSTEM Tablespace

KDDOUG_ Flashback Versions Query View row data at various commit times (Versions) within a timeframe Enhanced SQL syntax to retrieve rows VERSIONS BETWEEN Clause Timeframe can be Timestamp range or SCN range VERSIONS BETWEEN TIMESTAMP VERSIONS BETWEEN SCN

KDDOUG_ Flashback Versions Query Timeframe must fall within Undo Retention time Can be used to audit and analyze changes Can assist in testing Application process Only committed changes can be seen

KDDOUG_ Flashback Versions Query Syntax: SELECT * FROM DEPARTMENTS VERSIONS BETWEEN TIMESTAMP (SYSTIMESTAMP – INTERVAL 30 MINUTE) AND (SYSTIMESTAMP) WHERE DEPARTMENT_ID = 100;

KDDOUG_ Flashback Versions Query Pseudo-columns with returned rows: VERSIONS_STARTSCN If NULL, then version existed prior to the lower bound of SCN range, else the starting SCN for version of row data shown VERSIONS_ENDSCN If NULL, then shown version is current row or row is deleted, else the SCN when row version expired

KDDOUG_ Flashback Versions Query Pseudo-columns: VERSIONS_STARTTIME If NULL then version existed prior to the lower bound of timestamp range, else the starting timestamp for version of row data shown VERSIONS_ENDTIME If NULL then shown version is current row or row is deleted, else the timestamp when row version expired

KDDOUG_ Flashback Versions Query Pseudo-columns: VERSIONS_XID Transaction ID that created the row version VERSIONS_OPERATION DML Operation that created the row version (I=Insert, D=Delete, U=Update)

KDDOUG_ Flashback Versions Query Example SQL> select department_id, department_name, manager_id, 2 versions_starttime, versions_endtime, 3 versions_operation 4 from fv 5 versions between timestamp 6 (systimestamp - interval '5' minute) 7 and (systimestamp) 8 order by department_id, versions_starttime;

KDDOUG_ Flashback Versions Query Dept DeptName MGR_ID VERSIONS_STARTTIME VERSIONS_ENDTIME V Administration FEB PM U 10 Administration FEB PM 20 Marketing Purchasing Human Resources 203

KDDOUG_ Flashback Versions Query Example SQL> select versions_xid xid, versions_startscn start_scn, 2 versions_endscn end_scn, versions_operation oper, 3 department_id, department_name, manager_id 4 from fv 5 versions between scn 6 minvalue 7 and maxvalue;

KDDOUG_ Flashback Version Query XID START_SCN END_SCN O Dept DeptName MANAGER_ID E U 30 Purchasing DB U 10 Administration Administration Marketing Purchasing Human Resources rows selected.

KDDOUG_ Flashback Transaction Query View/Recover all data modifications at Transaction level FLASHBACK_TRANSACTION_QUERY view provides Undo SQL among other information SELECT ANY TRANSACTION privilege needed to access this view

KDDOUG_ Flashback Transaction Query Can be used to audit and analyze changes Can assist in testing Application process Only committed changes can be seen Supplements Flashback Versions Query

KDDOUG_ Flashback Transaction Query FLASHBACK_TRANSACTION_QUERY View Name Null? Type XID RAW(8) START_SCN NUMBER START_TIMESTAMP DATE COMMIT_SCN NUMBER COMMIT_TIMESTAMP DATE LOGON_USER VARCHAR2(30) UNDO_CHANGE# NUMBER OPERATION VARCHAR2(32) TABLE_NAME VARCHAR2(256) TABLE_OWNER VARCHAR2(32) ROW_ID VARCHAR2(19) UNDO_SQL VARCHAR2(4000)

KDDOUG_ Flashback Transaction Query Example: List transactions and affected tables in KIRTI schema after a certain date and time SQL> select xid, operation, start_scn, commit_scn 2 table_owner, table_name, logon_user, undo_sql 3 from flashback_transaction_query 4 where table_owner = 'KIRTI' 5 and start_timestamp >= 6 to_timestamp('02/03/06 17:27:00','MM/DD/YY HH24:MI:SS');

KDDOUG_ Flashback Transaction Query XID OPERATION START_SCN COMMIT_SCN TABLE_OWNER TABLE_NAME LOGON_USER UNDO_SQL DB UPDATE KIRTI FV KIRTI update "KIRTI"."FV" set "MANAGER_ID" = '200' where ROWID = 'AAANtjAAEAAAAGkAAA'; E UPDATE KIRTI FT KIRTI update "KIRTI"."FT" set "MANAGER_ID" = '204' where ROWID = 'AAANtkAAEAAAAGsAAC'; E UPDATE KIRTI FV KIRTI update "KIRTI"."FV" set "MANAGER_ID" = '114' where ROWID = 'AAANtjAAEAAAAGkAAC';

KDDOUG_ Flashback Database Set entire database to point in time in the past Similar to the database Point In Time Recovery Special setup is required to enable this functionality – Does not use undo segments and Recyclebin

KDDOUG_ Flashback Database Flashback Logs - New type of log files FB Logs are written to by a new background process RVWR FB Logs are kept in flashback area FB Logs contain before images of Oracle data blocks and are not archived

KDDOUG_ Flashback Database New initialization parameters DB_RECOVERY_FILE_DEST Default location of flash recovery area DB_RECOVERY_FILE_DEST_SIZE Hard limit for the disk space used by files in recovery area DB_FLASHBACK_RETENTION_TARGET Upper limit in minutes on how far database can be flashed back

KDDOUG_ Flashback Database New Views V$FLASH_RECOVERY_AREA_USAGE Usage information about flash recovery area V$FLASHBACK_DATABASE_LOG Information about flashback data, used for sizing flash recovery area V$FLASHBACK_DATABASE_STAT Information about I/O overhead of logging flashback data, estimated flashback spaces based on workloads

KDDOUG_ Flashback Database Set up database for Flashback mode Define new initialization parameters Mount the database Enable Archive log mode, if required Switch database to run in flashback mode alter database flashback on; Open database

KDDOUG_ Flashback Database Database can be flashed back using: SQL command SQL> flashback database to scn|timestamp; RMAN command RMAN> flashback database to scn|time; OEM Recovery Wizard Database must be in mount mode Database must be opened with resetlogs

KDDOUG_ Flashback Database Oracle10g R2 Restore points Aliases to SCN that you can use in flashback database command create restore point batch_start_1; create restore point batch_mid_1; flashback database to restore point batch_mid_1;

KDDOUG_ Flashback Database Oracle10g R2 Restore points V$RESTORE_POINT shows defined restore points Remove unwanted restore point drop restore point batch_start_1;

KDDOUG_ Questions ? Thank you. Contact: