Oracle Flashback Query 3


Published on

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Oracle is being used to handle some of the largest databaswes in the world. The availability of these databases is of the utmost importance to their owners. One of thye features concerning High Available is Oracle Flashback Query.
  • Oracle Flashback Query 3

    1. 1. Oracle Flashback Query Gwendolyn Wright 09/12/02
    2. 2. Agenda <ul><li>Introduction </li></ul><ul><li>Setting up Flashback Query </li></ul><ul><li>DBMS_FLASHBACK Package </li></ul><ul><li>DBMS_RESUMABLE Package </li></ul><ul><li>After Suspend Database Trigger </li></ul><ul><li>New Export/Import Feature </li></ul><ul><li>Flashback Query Advantages </li></ul><ul><li>Flashback Query Disadvantages </li></ul><ul><li>Possible Issues </li></ul>
    3. 3. Introduction <ul><li>Flashback Query allows the user to recover data to a point in time using SCN or a specific time. The undo tablespace and undo management features allow the user to reach back in time according to the parameters set. Suspending operations can allow the DBA to quickly correct problems and prevent down time. Export/Import allows for a quick recovery with new 9i features. </li></ul>
    4. 4. Setting up Oracle Flashback Query <ul><li>In most cases, setting up Oracle Flashback Query on the database is quite simple. </li></ul><ul><li>To set up Oracle Flashback Query on the database, the DBA must accomplish the following tasks: </li></ul><ul><ul><li>First, determine how far into the past the Flashback Query feature must reach. </li></ul></ul><ul><ul><li>The UNDO_RETENTION parameter can be set. </li></ul></ul><ul><ul><li>The UNDO_MANAGEMENT parameter must be set to = AUTO </li></ul></ul><ul><ul><li>An UNDO tablespace must be created with enough space available to accommodate the amount of data that will be updated through Flashback Query. </li></ul></ul><ul><ul><li>The EXECUTE privilege must be granted to any users or roles that will need to access the DBMS_FLASHBACK package. </li></ul></ul>
    5. 5. The DBMS_FLASHBACK Package <ul><li>DBMS_FLASHBACK package is used to implement Oracle Flashback Query. The package has several procedures as follows: </li></ul><ul><ul><li>ENABLE_AT_TIME – This procedure allows the user or developer to enable Flashback for a certain time in the past. </li></ul></ul><ul><ul><li>The argument must be of the type TIMESTAMP . Either the TIMESTAMP format (according to the database NLS settings) or TO_TIMESTAMP function can be used to specify whatever timestamp format is desired. </li></ul></ul>
    6. 6. The DBMS_FLASHBACK Package <ul><li>Oracle will set the Flashback version of the database to a SCN that is within five minutes of the time specified. </li></ul><ul><li>If DBMS_FLASHBACK.ENABLE_AT_TIME is called without the TIMESAMP argument, Oracle will use the default, which is 12:00 A.M. of the present day. </li></ul><ul><ul><li>The system clock will continue to report the real system time. </li></ul></ul><ul><ul><li>DML and DDL cannot be performed while in Flashback mode. </li></ul></ul><ul><ul><li>Cursors that are opened in flashback mode can be used to perform DML after flashback mode is cancelled. </li></ul></ul><ul><li>ENABLE_AT_SYSTEM_CHANGE_NUMBER – This procedure allows the user or developer to enable Flashback for a certain system change number in the past. </li></ul><ul><ul><li>The argument must of type NUMBER. </li></ul></ul>
    7. 7. The DBMS_FLASHBACK Package <ul><li>GET_SYSTEM_CHANGE_NUMBER – This is a function that returns the current system change number for the system. It can be used to determine the current SCN so that the current version of the database can be stored as a snapshot. </li></ul><ul><li>DISABLE – This procedure disabled the package. </li></ul>
    8. 8. Resumable Statement and DBMS_RESUMABLE <ul><li>The DBMS_RESUMABLE package allows developers to write long running batch jobs without accommodating space-related errors. </li></ul><ul><li>Operations that run out of space can be suspended and then resumed from the point of suspension. </li></ul><ul><ul><li>If an error situation occurs that requires DBA intervention, the DBA can temporarily suspend the operation until he or she corrects the condition and then resume the operation. </li></ul></ul><ul><ul><li>With DBMS_RESUMABLE , operations can automatically suspend themselves, wait for the error condition to be corrected, and then automatically resume and complete. </li></ul></ul><ul><ul><li>The transaction is suspended along with the operation. Resources are still held. </li></ul></ul><ul><ul><li>Multiple suspensions and resumptions can take place. </li></ul></ul><ul><ul><li>A timeout period (default two hours) can be set after which an operation will terminate. </li></ul></ul>
    9. 9. DBMS_RESUMABLE – Procedures and Functions <ul><li>SET_TIMEOUT() – This procedure sets the resumable timeout period for the current session only. The default timeout value for resumable statements is two hours. </li></ul><ul><li>SET_SESSION_TIMEOUT() – The timeout period can be set for any session with this procedure by supplying the session ID. The timeout period is specified in seconds. </li></ul><ul><li>GET_TIMEOUT() – This is a function that will return the current resumable timeout setting for this session. </li></ul><ul><li>GET_SESSION_TIMEOUT() – This function returns the timeout period that has been set for a session specified with the session ID. </li></ul><ul><li>SPACE_ERROR_INFO() – This function returns any information it can find in the error stack that is space-related. FALSE will be returned if no such information exists. </li></ul><ul><li>ABORT() – This procedure will cause a resumable operation to terminate with an exception. </li></ul>
    10. 10. After Suspend Database Trigger <ul><li>If an operation suspends for any reason, there is good reason for the appropriate DBA to be notified. The new AFTER SUSPEND trigger can be used to perform this needed function . </li></ul>
    11. 11. New Export/Import feature <ul><li>Export/Import in Flashback query mode can use the where clause to get only the records needed. </li></ul><ul><li>The export and import utility now supports the new parameters for resumable space allocation: </li></ul><ul><ul><li>RESUMABLE </li></ul></ul><ul><ul><li>RESUMABLE_NAME </li></ul></ul><ul><ul><li>RESUMABLE_TIMEOUT </li></ul></ul><ul><li>The Export and Import utilities also support the following new parameters: </li></ul><ul><ul><li>FLASHBACK_SCN </li></ul></ul><ul><ul><li>FLASHBACK_TIME </li></ul></ul>
    12. 12. FLASHBACK Query Advantages <ul><li>Creates a read consistent view. </li></ul><ul><li>The time or SCN gives greater ability to recover to a point in time. </li></ul><ul><li>Tables and objects can be queried directly with select statements. </li></ul><ul><li>Constraints are in effect so application code is valid. </li></ul><ul><li>Cursors in flashback sessions can perform DDL after the session is terminated. </li></ul><ul><li>DBMS_FLASHBACK is designed for authorized users. </li></ul><ul><li>The EXPORT command supports exporting data at the tablespace level. The new TABLESPACES parameter supports exporting tablespaces. </li></ul>
    13. 13. Flashback Query Disadvantages <ul><li>The execute privilege must be given to authorized users. </li></ul><ul><li>The DBA might be engaged in the event the authorized user is not able to recover the data appropriately to a point in time or SCN. </li></ul><ul><li>Space Requirements – The UNDO Tablspace most be large enough to hold all of the transactions that you are bringing back. </li></ul><ul><li>Performance – Possible degradation in performance for OLTP or mixed environment (OLTP and Batch). </li></ul>
    14. 14. Possible Issues <ul><li>The system clock time may not match the SCN, so, Flashback Query could think that your query time is earlier than the table creation time and throw an error. </li></ul><ul><li>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. </li></ul><ul><li>You can never flashback more than 5 days, irrespective of UNDO_RETENTION. </li></ul>
    15. 15. Where to Get More Information <ul><li>Oracle9i Recovering Lost Data – Oracle Metalink – Doc 174425.1 </li></ul><ul><li>Parameters FLASHBACK_SCN & FLASHBACK_TIME: Point in Time Export – Oracle Metalink – Doc 204334.1 </li></ul><ul><li>Flashback Query: Confusion on SCN based – Oracle Metalink – Doc 302681.999 </li></ul><ul><li>Oracle 9i New Features Flashback – Oracle Metalink – Doc 143217.1 </li></ul>