Flashback Query allows users to see the view of past data, If in case some data or table is being deleted by the user, then the flashback query provides us an opportunity to view that data again and perform manipulations over it.
In flashback queries we have an concept of flash area, in flash area we store the deleted data which can be viewed if needed in future.
To use the feature of flashback query, our server must be configured according to automatic undo management.If our system supports the traditional approach of rollback then we can not perform flashback query on such systems.
We can enable the flashback query using the package DBMS_FLASHBACK. This package enables us to view the data in past by specifying the System change number or the exact time in the past.
How to use DBMS_FLASHBACK :
EXECUTE Dbms_Flashback.Enable_At_System_Change_Number(647392649); EXECUTE Dbms_Flashback.Enable_At_Time('19-APR-2020 11:00:00);
Example of Flashback Query :
If we want to view a past data which is being deleted by mistake.The data consists of students table and it is being deleted at 11:05 AM on 19-APR-2020.To access the data we can use flashback query either by giving exact time or by mentioning the system change number.
Limitations Flashback Query :
- Flashback query only works on those systems which supports automatic undo management.
- Systems having traditional approach of rollback does not supports flashback query.
- We can not use DDL (Data Definition Language) or DML (Data Manipulation Language) while performing flashback query.
- Flashback query does not reverse the DDL(Data Definition Language) commands.
- Flashback query can perform manipulations in DDL(Data Definition Language) commands.
- We can not apply flashback queries on functions, Packages, Procedures and triggers.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- SQL | Top-N Queries
- SQL | Sub queries in From Clause
- Nested Queries in SQL
- SQL queries on FILM Database
- Types of Spatial Queries in DBMS
- Range Queries for finding the Sum of all even parity numbers
- Range Update Queries to XOR with 1 in a Binary Array.
- How to Run Synchronous Queries using sync-sql Module in Node.js ?
- Check if a substring can be Palindromic by replacing K characters for Q queries
- Range Queries to find the Element having Maximum Digit Sum
- Count of elements which are power of 2 in a given range subarray for Q queries
- Find the element having maximum set bits in the given range for Q queries
- Mitigation of SQL Injection Attack using Prepared Statements (Parameterized Queries)
- Queries for greatest pair sum in the given index range using Segment Tree
- Range Queries to count the number of even parity values with updates
- Range Queries for number of Armstrong numbers in an array with updates
- Count numbers divisible by K in a range with Fibonacci digit sum for Q queries
- Queries for maximum and minimum difference between Fibonacci numbers in given ranges
- Queries for the count of even digit sum elements in the given range using Segment Tree.
- Array Range Queries to find the Maximum Armstrong number with updates
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.