Database Reference
In-Depth Information
The Flashback Query successfully returned the missing row, but we have only displayed
it. We haven't actually recovered it. To do so, we can simply run the same query but wrap it
inside an INSERT statement, as shown here:
SQL> insert into job_history
2 (select * from job_history
3 as of timestamp(
4 to_timestamp('23-AUG-2013 11:50:00','DD-MON'))
5 where employee_id = 102);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from job_history;
EMPLOYEE_ID START_DAT END_DATE JOB_ID DEPARTMENT_ID
----------- --------- --------- ---------- -------------
102 13-JAN-01 24-JUL-06 IT_PROG 60
101 21-SEP-97 27-OCT-01 AC_ACCOUNT 110
101 28-OCT-01 15-MAR-05 AC_MGR 110
201 17-FEB-04 19-DEC-07 MK_REP 20
114 24-MAR-06 31-DEC-07 ST_CLERK 50
122 01-JAN-07 31-DEC-07 ST_CLERK 50
200 17-SEP-95 17-JUN-01 AD_ASST 90
176 24-MAR-06 31-DEC-06 SA_REP 80
176 01-JAN-07 31-DEC-07 SA_MAN 80
200 01-JUL-02 31-DEC-06 AC_ACCOUNT 90
10 rows selected.
We have now successfully recovered from the accidental deletion and, as you can see, the
effort was minimal.
In the example, our Flashback Query pulled data only from a single table and at a
single point in time. Flashback Query is not limited to such simple queries. It can be used
in multitable join queries as well. It can also be mixed and matched with tables that are
not flashed back as well as tables that are flashed back to a different point in time. Look
at the following example:
SQL> select e.last_name, d.department_name, j.job_title
2 from employees as of timestamp(to_timestamp('23-AUG-2013 11:50:00',
Search WWH ::




Custom Search