+ All Categories
Home > Documents > 9i Falsback Query

9i Falsback Query

Date post: 10-Feb-2018
Category:
Upload: sambamurthy-rachapudi
View: 229 times
Download: 0 times
Share this document with a friend

of 17

Transcript
  • 7/22/2019 9i Falsback Query

    1/17

    1

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Oracle 9i New Features

    --Sridevi Edupuganti

  • 7/22/2019 9i Falsback Query

    2/17

    2

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Oracle9i FlashbackQuery

    Scope & Application

    Package and Procedures Used

    Prerequisites List of steps

    Oracle9i Flashback Example

    Performance considerations Limitations of Flashback query

  • 7/22/2019 9i Falsback Query

    3/17

    3

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    SCOPE &

    APPLICATION

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

  • 7/22/2019 9i Falsback Query

    4/17

    4

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Package and procedures

    used

    Package

    DBMS_FLASHBACK

    Procedures disable

    enable_at_time

  • 7/22/2019 9i Falsback Query

    5/17

    5

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Prerequisites

    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.

  • 7/22/2019 9i Falsback Query

    6/17

    6

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    undo_retention

    ALTER SYSTEM SET undo_retention = 1200

    This command sets 1200 seconds during which

    undo information is retained. All committed undoinformation in the system is retained for at least

    20 minutes(20*60=1200)

    This ensures that all queries running for 20minutes or less do not receive an ORA-1555

    (snapshot too old) error, under normal

    circumstances.

  • 7/22/2019 9i Falsback Query

    7/177

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    List of steps

    step1: a) Create a FLASH user

    b) grant the required privileges

    step2: a) Create a user table and insert rowsb) Create another table to keep

    the time when rows existed

    step 3: a) Execute disable procedure

    b) Delete a row

    step 4: Enable Flashback

  • 7/22/2019 9i Falsback Query

    8/178

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Flashback Example

    Step 1

    Set up User

    Create a flash userSQL> create user flash identified by gordon;

    Grant required privileges

    SQL>grant connect, resource to flash;SQL>grant execute on dbms_flashback to flash;

  • 7/22/2019 9i Falsback Query

    9/179

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Flashback Example

    Step 2 Setup Table

    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);

  • 7/22/2019 9i Falsback Query

    10/1710

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Flashback Example

    SQL> SELECT * FROM tst;

    T

    ----------1

    2

  • 7/22/2019 9i Falsback Query

    11/1711

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Flashback Example

    Using disable procedure

    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

    Step 3

  • 7/22/2019 9i Falsback Query

    12/1712

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Flashback Example

    Using enable procedure

    SQL> declarerestore_scn date;

    beginselect date_scn_tracking into restore_scn

    from keep_date;dbms_flashback.enable_at_time(restore_scn);

    end;

    Step 4

  • 7/22/2019 9i Falsback Query

    13/1713

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Result after using enable

    procedure

    SQL> SELECT * FROM tst;

    T

    ----------12

    Flashback is able to display the 2 rows that existed in

    the past, before the row deletion.

  • 7/22/2019 9i Falsback Query

    14/1714

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Performance

    considerations

    When a query is executed for a time in the past, asnapshot of data as it was at that time needs to berecreated using "undo" data. For every piece of data

    that has changed since the time of the FlashbackQuery, the corresponding undo data needs to beretrieved and compiled. Hence the performance ofthe Flashback Query degrades significantly as thevolume of data which needs to "recreated" increases.

    f

  • 7/22/2019 9i Falsback Query

    15/1715

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Performance

    considerations

    Because of this, a Flashback Query works bestwhen it is used to select a small set of data,preferably using indexes. If a Flashback Query

    must perform a full table scan, its performancewill depend on the amount of DML activitiesperformed on that table between the presentand the time of the data that the FlashbackQuery is retrieving.

  • 7/22/2019 9i Falsback Query

    16/1716

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu

    Limitations of Flashbackquery:

    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.

  • 7/22/2019 9i Falsback Query

    17/1717

    ..our people make the dif ference.. I nstituti onalizing Excell ence

    Main Menu


Recommended