Recently in our workshop, my colleague deleted more than 10,000 rows. And he then commits the changes. After some time, he identified the delete was wrong.
How to recover this data? It’s a big question for him. Usually, after committing, it’s hard to recover data (otherwise restore the data). Finally, from Oracle Flashback Table, he could recover the data.
What is Flashback Table in Oracle?
Oracle Flashback Technology is a group of Oracle Database features that let you view past states of database objects or return database objects to a previous state without using point-in-time media recovery.
With flashback features, you can:
- Perform queries that return past data
- Perform queries that return metadata that shows a detailed history of changes to the database
- Recover tables or rows to a previous point in time
- Automatically track and archive transactional data changes
- Rollback a transaction and its dependent transactions while the database remains online
Architecture of Flashback Table
SQL Query to recover data
Here is the example SQL query. You can use it to recover data from the flashback table to a specific point in time.
SELECT * FROM employees AS OF TIMESTAMP TO_TIMESTAMP('2004-04-04 09:30:00', 'YYYY-MM-DD HH:MI:SS') WHERE last_name = 'Chung';
The as of timestamp to execute it, you need privileges’. Here is a solution to resolve the issue.
References & more examples
Here are ideas to write Echo command in Linux shell script.
This topic shows to use the sed command in Linux to get a matching string
An example SQL query that works in MySQL shows how to use Boolean Operators in the WHERE clause.