Documente Academic
Documente Profesional
Documente Cultură
Institutionalizing Excellence
Main Menu
Scope & Application Package and Procedures Used Prerequisites List of steps Oracle9i Flashback Example Performance considerations Limitations of Flashback query
Main Menu
This is intended for anyone willing to use Flashback for any user error recovery.
Main Menu
Package
DBMS_FLASHBACK
Procedures
disable enable_at_time
Main Menu
Prerequisites
..our people make the difference.. Institutionalizing Excellence
undo_retention
..our people make the difference.. Institutionalizing Excellence
ALTER SYSTEM SET undo_retention = 1200 This command sets 1200 seconds during which undo information is retained. All committed undo information in the system is retained for at least 20 minutes(20*60=1200) This ensures that all queries running for 20 minutes or less do not receive an ORA-1555 (snapshot too old) error, under normal circumstances.
Main Menu
6
List of steps
..our people make the difference.. Institutionalizing Excellence
step1: step2:
step 3:
step 4:
a) Create a FLASH user b) grant the required privileges a) Create a user table and insert rows b) Create another table to keep the time when rows existed a) Execute disable procedure b) Delete a row Enable Flashback
Main Menu
Flashback Example
..our people make the difference.. Institutionalizing Excellence
Step 1
Set up User
Create a flash user SQL> create user flash identified by gordon; Grant required privileges SQL>grant connect, resource to flash; SQL>grant execute on dbms_flashback to flash;
Main Menu
Flashback Example
..our people make the difference.. Institutionalizing Excellence
Setup Table
Step 2
Create a user table CREATE TABLE tst(t number(5)); Insert values into the above table INSERT INTO tst VALUES(1); INSERT INTO tst VALUES(2); COMMIT; Create another table to keep the time when rows existed CREATE TABLE keep_date (date_scn_tracking date);
Main Menu
9
Flashback Example
..our people make the difference.. Institutionalizing Excellence
Main Menu
10
Step 3
Step 4
SQL> declare restore_scn date; begin select date_scn_tracking into restore_scn from keep_date; dbms_flashback.enable_at_time(restore_scn); end;
Main Menu
12
SQL> SELECT * FROM tst; T ---------1 2 Flashback is able to display the 2 rows that existed in the past, before the row deletion.
Main Menu
13
Performance considerations
..our people make the difference.. Institutionalizing Excellence
When a query is executed for a time in the past, a snapshot of data as it was at that time needs to be recreated using "undo" data. For every piece of data that has changed since the time of the Flashback Query, the corresponding undo data needs to be retrieved and compiled. Hence the performance of the Flashback Query degrades significantly as the volume of data which needs to "recreated" increases.
Main Menu
14
Performance considerations
..our people make the difference.. Institutionalizing Excellence
Because of this, a Flashback Query works best when it is used to select a small set of data, preferably using indexes. If a Flashback Query must perform a full table scan, its performance will depend on the amount of DML activities performed on that table between the present and the time of the data that the Flashback Query is retrieving.
Main Menu
15
1. Specifying a time will only find the flashback copy to the nearest five minute interval. This is also true of the get_system_change_number. 2. You can never flashback more than 5 days, irrespective of UNDO_RETENTION.
Main Menu
16
Institutionalizing Excellence
Main Menu
17