Database Reference
In-Depth Information
In our next example, we will use some of these pseudocolumns to create a simple history
report covering the salary changes of our sample employee. The query is shown here:
SQL> select to_char(versions_starttime,'DD-MON HH:MI') "START DATE",
to_char (versions_endtime, 'DD-MON HH:MI') "END DATE",
versions_operation,
employee_id,
salary
from employees
versions between scn minvalue and maxvalue
where employee_id = 193;
START DATE END DATE V EMPLOYEE_ID SALARY
------------ ------------ - ----------- ----------
13-MAY 09:13 U 193 2108.93
13-MAY 09:12 13-MAY 09:13 U 193 4217.85
13-MAY 09:08 13-MAY 09:12 U 193 4017
13-MAY 08:15 13-MAY 09:08 I 193 3900
This simple query has produced a comprehensive report showing a wealth of information
regarding this employee's salary history. By reading from the bottom up, you can see the date
and time that the employee was first inserted into the EMPLOYEES table (presumably the day he
was hired), as well as his starting salary.
The next lines show the dates, times, amounts, and durations of each salary change for
the employee. You will notice that the last line (the top one) has no value for END DATE . This
shows that this value still represents the current salary for the employee.
The Flashback Version Query can also be used in DDL and DML subqueries.
So, in conclusion, Flashback Version Query allows you to see into the past to view the
history of data changes in the database. It takes the power of Flashback Query a step further
and provides you with additional metadata to identify changes in more detail. It even allows
you to identify the specific transaction that made the change.
But wouldn't it be nice if you could drill down even further, to see specific details
about that transaction? Unfortunately, Flashback Version Query does not allow you to
do that. Instead, you need to move ahead to the next section and learn about the tool
that will allow you to do that: Flashback Transaction Query.
Detecting Changes with Flashback Transaction Query
Flashback Transaction Query is a diagnostic tool used to identify changes made to the data-
base at the transaction level. Much like Flashback Version Query, Flashback Transaction
Query allows you to identify all changes made between two specific points in time. But
Search WWH ::




Custom Search