文档课题:测试闪回查询功能.标签:SALARY,salary,闪回,name,查询,employees03,测试,Kevin,first From: https://blog.51cto.com/u_12991611/5907418
应用场景:
a、恢复丢失的数据或撤消不正确的已提交的更改.如commit错误的dml事务,此时便可通过闪回查询将数据找回.
b、将当前数据与过去某一时刻的数据进行比较.
实际操作:
SQL> select employee_id,first_name,last_name,hire_date,salary from employees03;
EMPLOYEE_ID FIRST_NAME LAST_NAME HIRE_DATE SALARY
----------- -------------------- --------------- ----------------------------------- ----------
100 Steven King 17-JUN-11 24000
101 Neena Kochhar 21-SEP-09 17000
102 Lex De Haan 13-JAN-09 17000
103 Alexander Hunold 03-JAN-14 9000
104 Bruce Ernst 21-MAY-15 6000
107 Diana Lorentz 07-FEB-15 4200
124 Kevin Mourgos 16-NOV-15 5800
141 Trenna Rajs 17-OCT-11 3500
142 Curtis Davies 29-JAN-13 3100
143 Randall Matos 15-MAR-14 2600
144 Peter Vargas 09-JUL-14 2500
EMPLOYEE_ID FIRST_NAME LAST_NAME HIRE_DATE SALARY
----------- -------------------- --------------- ----------------------------------- ----------
149 Eleni Zlotkey 29-JAN-16 10500
174 Ellen Abel 11-MAY-12 11000
176 Jonathon Taylor 24-MAR-14 8600
178 Kimberely Grant 24-MAY-15 7000
200 Jennifer Whalen 17-SEP-11 4860
201 Michael Hartstein 17-FEB-12 13000
202 Pat Fay 17-AUG-13 6000
205 Shelley Higgins 07-JUN-10 12008
206 William Gietz 07-JUN-10 12008
20 rows selected.
SQL> select salary from employees03 where first_name='Kevin';
SALARY
----------
5800
SQL> update employees03 set salary=8500 where first_name='Kevin';
1 row updated.
SQL> commit;
Commit complete.
SQL> select salary from employees03 where first_name='Kevin';
SALARY
----------
8500
SQL> select salary from employees03 as of timestamp (systimestamp-interval '5' minute) where first_name='Kevin';
SALARY
----------
5800
SQL> select salary from employees03 as of timestamp (systimestamp-interval '1440' minute) where first_name='Kevin';
SALARY
----------
5800
说明:如上使用as of timestamp语句便可查出5分钟前或1天前的数据.