Presentation is loading. Please wait.

Presentation is loading. Please wait.

ORACLE FLASHBACK. Flashback Flashback a nivel de base de datos Flashback a nivel de tabla Flashback a nivel de tabla borrada Flashback query Flashback.

Similar presentations


Presentation on theme: "ORACLE FLASHBACK. Flashback Flashback a nivel de base de datos Flashback a nivel de tabla Flashback a nivel de tabla borrada Flashback query Flashback."— Presentation transcript:

1 ORACLE FLASHBACK

2 Flashback Flashback a nivel de base de datos Flashback a nivel de tabla Flashback a nivel de tabla borrada Flashback query Flashback query versions Flashback transaction query

3 Flashback Query Oracle Flashback Query allows users to see a consistent view of the database as it was at a point in the past. This functionality allows comparative reporting over time and recovery from logical corruptions.

4 How does the flashback query work? The Oracle database uses a version based read consistency mechanism by saving an image of the data prior to making any modifications. These changes are stored in the undo tablespace (or Rollback Segments). Should the user later decide not to commit the transaction or if the operation was not successful, Oracle uses thedata saved in the undo tablespace to recreate the original data

5 How does the flashback query work? The undo data is also used to generate a snapshot of data consistent to a point in time when a query was started if another user has modified the underlying data. Flashback Query relies on the same mechanism to construct an image of the data as it existed at a time in the past. The undo data, therefore, must be available in order for a Flashback Query to be successful.

6 How does the flashback query work? Oracle9i’s Automatic Undo Management feature allows administrators to specify how long they wish to retain the undo data using the UNDO_RETENTION initialization parameter. By using this parameter and sizing the undo tablespace appropriately, DBAs can control how far back a Flashback Query can go.

7 PRE-REQUISITES Oracle Flashback Query can only be used if the server is configured to use Automatic Undo Management, rather than traditional rollback segments. The maximum time period that can be flashbacked to is defined using the UNDO_RETENTION parameter in the init.ora file. Alternatively, this parameter can be set using:Automatic Undo Management Alter system set undo_management=auto scope=spfile; ALTER SYSTEM SET UNDO_RETENTION = ; GRANT FLASHBACK ANY TABLE TO USER;

8 FLASHBACK QUERY Enable the undo_retention Grant privileges FLASHBACK ANY TABLE Select * from SCHEMA.TABLE AS OF TIMESTAMP TO_TIMESTAMP(‘DD-MM-YYYY HH:MM:SS'); Select * from SCHEMA.TABLE AS OF SCN (#); EXECUTE Dbms_Flashback.Enable_At_System_Change_Number(123) ;EXECUTE Dbms_Flashback.Enable_At_Time('28-AUG-01 11:00:00'); EXECUTE Dbms_Flashback.Disable;

9 Flashback Query Sample Alter System Set undo_retention = 1200; (sys) Shutdown immediate Startup Creamos una copia de la tabla para efectuar el ejemplo: Create table Empleados as Select * from Emp; (scott) Delete from Empleados Where Deptno = 10; ( :16:04)  11:16:14  commit; Select * from SCOTT.EMPLEADOS AS OF TIMESTAMP TO_TIMESTAMP(' :16:14')

10 Flashback Query Sample ORACLE 9iR2 Ver que datos no se encuentran o fueron borrados de la otra tabla: Select * from EMPLEADOS AS OF TIMESTAMP TO_TIMESTAMP(' :16:14') MINUS Select * from EMPLEADOS Restauramos la información en la tabla: INSERT INTO EMPLEADOS (Select * from EMPLEADOS AS OF TIMESTAMP TO_TIMESTAMP(' :16:14') MINUS Select * from EMPLEADOS)

11 Flashback Query Sample ORACLE 9iR1 Grant execute on dbms_flashback to scott; 13:17:55 SQL> Delete from empleados where deptno = 20; 13:18:06 SQL> commit; EXECUTE Dbms_Flashback.Enable_At_Time(' :18:06 PM') Select * from Empleados; Ejecutar Script Deshabilitar Flashback EXECUTE Dbms_Flashback.disable;

12 Flashback Query Sample 9iR1

13 Flashback Query Sample ORACLE 9iR1 Para conocer el ultimo SCN: – DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER;

14 Flashback Options ORACLE 10g Flashback Version Query Flashback Transaction Query


Download ppt "ORACLE FLASHBACK. Flashback Flashback a nivel de base de datos Flashback a nivel de tabla Flashback a nivel de tabla borrada Flashback query Flashback."

Similar presentations


Ads by Google