Tuesday 16 April 2019

How to retrieve the deleted rows in a table

You can use FLASHBACK TABLE to retrieve your rows. But before that you must enable row movement by following query

ALTER TABLE hr.employees ENABLE ROW MOVEMENT;
And there after firing the below query for the particular timestamp when your rows were existing at that time.

FLASHBACK TABLE hr.employees TO TIMESTAMP TO_TIMESTAMP('17-10-2011 12:19:00','DD-MM-YYYY HH24:MI:SS');

Example: select * from apps.PER_CONTACT_RELATIONSHIPS as of timestamp to_timestamp('31-05-2015 04:00:00','DD-MM-YYYY HH24:MI:SS');

FLASHBACK is used to retrive the dropped tables.

Use the following to retrieve the deleted and committed rows

select * from table_name as of timestamp to_timestamp(sysdate-(360/1440))
The above sample SQL will fetch the status of data in the table 6 hours earlier.

No comments:

Post a Comment