How to Recover Deleted Data in Oracle

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.

From Oracle Ver. 9i Oracle has introduced the Flashback Query feature. It is handy to recover from accidental statement failures.

Advertisements

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

The architecture of the flashback table
The architecture of the 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

Related posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.