Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "KDDOUG_0719071 Oracle10g: Behind the Scenes of Flashback Technologies DOUG Meeting July 19, 2007 Kirtikumar Deshpande."— Presentation transcript:

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

2 KDDOUG_0719072 About Me Senior Oracle DBA Idearc Media Phone Directories Publication

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

4 KDDOUG_0719074 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

5 KDDOUG_0719075 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

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

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

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

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

10 KDDOUG_07190710 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

11 KDDOUG_07190711 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.

12 KDDOUG_07190712 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

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

14 KDDOUG_07190714 V$UNDOSTAT View New Columns MAXQUERYID ACTIVEBLKS UNEXPIREDBLKS EXPIREDBLKS TUNED_UNDORETENTION

15 KDDOUG_07190715 V$UNDOSTAT Example BEGIN_TIME END_TIME MAXQUERYID MAXQL TUNEDRET ACTBLK UNXPBLK XPBLK ------------------------ ------------------------- ------------------- ----------- -------------- ---------- ----------- ---------- 22-FEB-06 23:54:49 23-FEB-06 00:04:49 0 1800 448 256 142416 22-FEB-06 23:44:49 22-FEB-06 23:54:49 0 1800 448 130176 12496 22-FEB-06 23:34:49 22-FEB-06 23:44:49 b1z64uk2y5p6v 5997 6358 448 130048 12496 22-FEB-06 23:24:49 22-FEB-06 23:34:49 b1z64uk2y5p6v 5392 5752 448 130048 12496 22-FEB-06 23:14:49 22-FEB-06 23:24:49 b1z64uk2y5p6v 4785 5145 448 130048 12496 22-FEB-06 23:04:49 22-FEB-06 23:14:49 b1z64uk2y5p6v 4178 4538 448 130048 12496 22-FEB-06 22:54:49 22-FEB-06 23:04:49 b1z64uk2y5p6v 3571 3932 448 129792 12496 22-FEB-06 22:44:49 22-FEB-06 22:54:49 b1z64uk2y5p6v 2965 3325 448 129664 12496 22-FEB-06 22:34:49 22-FEB-06 22:44:49 b1z64uk2y5p6v 2357 2720 448 129408 13392 22-FEB-06 22:24:49 22-FEB-06 22:34:49 b1z64uk2y5p6v 1752 2112 448 129408 13264 22-FEB-06 22:14:49 22-FEB-06 22:24:49 b1z64uk2y5p6v 1145 1800 448 129408 13136 22-FEB-06 22:04:49 22-FEB-06 22:14:49 b1z64uk2y5p6v 538 1800 448 127616 13264 22-FEB-06 21:54:49 22-FEB-06 22:04:49 5rv0j37z1ztgm 203 1800 448 256 15952 22-FEB-06 21:44:49 22-FEB-06 21:54:49 ac20brc1kdgdx 927 1800 448 256 15952 22-FEB-06 21:34:49 22-FEB-06 21:44:49 ac20brc1kdgdx 320 1800 448 128 16080

16 KDDOUG_07190716 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

17 KDDOUG_07190717 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( );

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

19 KDDOUG_07190719 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 --------------------- ------------------------------ 10 Administration 20 Marketing 30 Purchasing 40 Human Resources

20 KDDOUG_07190720 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

21 KDDOUG_07190721 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: 3076151 - Unpublished Internal GTT SYS_TEMP_FBT not dropped after flashback operation

22 KDDOUG_07190722 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;

23 KDDOUG_07190723 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

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

25 KDDOUG_07190725 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;

26 KDDOUG_07190726 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.

27 KDDOUG_07190727 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.

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

29 KDDOUG_07190729 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

30 KDDOUG_07190730 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

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

32 KDDOUG_07190732 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

33 KDDOUG_07190733 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

34 KDDOUG_07190734 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)

35 KDDOUG_07190735 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;

36 KDDOUG_07190736 Flashback Versions Query Dept DeptName MGR_ID VERSIONS_STARTTIME VERSIONS_ENDTIME V ------ ---------------------- ---------- ----------------------------- ---------------------------- - 10 Administration 888 23-FEB-06 05.27.01 PM U 10 Administration 200 23-FEB-06 05.27.01 PM 20 Marketing 201 30 Purchasing 114 40 Human Resources 203

37 KDDOUG_07190737 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;

38 KDDOUG_07190738 Flashback Version Query XID START_SCN END_SCN O Dept DeptName MANAGER_ID ------------------------ --------------- --------------- - ------- ------------------- ----------------- 08002400E9080000 5373412 U 30 Purchasing 777 06000000DB080000 5373406 U 10 Administration 888 5373406 10 Administration 200 20 Marketing 201 5373412 30 Purchasing 114 40 Human Resources 203 6 rows selected.

39 KDDOUG_07190739 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

40 KDDOUG_07190740 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

41 KDDOUG_07190741 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)

42 KDDOUG_07190742 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');

43 KDDOUG_07190743 Flashback Transaction Query XID OPERATION START_SCN COMMIT_SCN TABLE_OWNER TABLE_NAME ----------------------- --------------- -------------- ----------------- ------------------ ----------------- LOGON_USER ---------------- UNDO_SQL ------------------------------------------------------------------------------------------ 06000000DB080000 UPDATE 5373227 5373406 KIRTI FV KIRTI update "KIRTI"."FV" set "MANAGER_ID" = '200' where ROWID = 'AAANtjAAEAAAAGkAAA'; 08002400E9080000 UPDATE 5373406 5373412 KIRTI FT KIRTI update "KIRTI"."FT" set "MANAGER_ID" = '204' where ROWID = 'AAANtkAAEAAAAGsAAC'; 08002400E9080000 UPDATE 5373406 5373412 KIRTI FV KIRTI update "KIRTI"."FV" set "MANAGER_ID" = '114' where ROWID = 'AAANtjAAEAAAAGkAAC';

44 KDDOUG_07190744 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

45 KDDOUG_07190745 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

46 KDDOUG_07190746 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

47 KDDOUG_07190747 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

48 KDDOUG_07190748 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

49 KDDOUG_07190749 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

50 KDDOUG_07190750 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;

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

52 KDDOUG_07190752 Questions ? Thank you. Contact: KD_U4@yahoo.com


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

Similar presentations


Ads by Google