Sunteți pe pagina 1din 17

..our people make the difference..

Institutionalizing Excellence

Oracle 9i New Features


--Sridevi Edupuganti

Main Menu

Oracle9i Flashback Query


..our people make the difference.. Institutionalizing Excellence

Scope & Application Package and Procedures Used Prerequisites List of steps Oracle9i Flashback Example Performance considerations Limitations of Flashback query

Main Menu

SCOPE & APPLICATION


..our people make the difference.. Institutionalizing Excellence

This is intended for anyone willing to use Flashback for any user error recovery.

Main Menu

Package and procedures used


..our people make the difference.. Institutionalizing Excellence

Package
DBMS_FLASHBACK

Procedures
disable enable_at_time

Main Menu

Prerequisites
..our people make the difference.. Institutionalizing Excellence

Set up the database for Flashback Use


Prerequisite : Set init.ora parameter
UNDO_MANAGEMENT = AUTO UNDO_TABLESPACE =UNDOTBS UNDO_RETENTION =1200
The ALTER SYSTEM SET undo_retention = 1200 urges Oracle to keep undo information for 1200 seconds. Main Menu
5

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

SQL> SELECT * FROM tst; T ---------1 2

Main Menu

10

Flashback Example Using disable procedure


..our people make the difference.. Institutionalizing Excellence

Step 3

SQL> execute dbms_flashback.disable;


SQL> INSERT INTO keep_date select sysdate from dual; SQL> COMMIT; SQL>DELETE FROM tst WHERE t = 1; SQL>COMMIT; SQL> SELECT * FROM tst; T ---------2
Main Menu
11

Flashback Example Using enable procedure


..our people make the difference.. Institutionalizing Excellence

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

Result after using enable procedure


..our people make the difference.. Institutionalizing Excellence

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

Limitations of Flashback query:


..our people make the difference.. Institutionalizing Excellence

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

..our people make the difference..

Institutionalizing Excellence

Main Menu

17

S-ar putea să vă placă și