SQL> select * from test
2 as of timestamp(systimestamp - interval '1' day)
3 where test1='love';
as of timestamp(systimestamp - interval '1' day)
*
ERROR 位于第 2 行:
ORA-00933: SQL 命令未正确结束
Using Flashback Queries: Example
The following statements show a current value from the sample table hr.employees and then changes the value:
SELECT salary FROM employees
WHERE last_name = 'Chung';
SALARY
----------
3800
UPDATE employees SET salary = 4000
WHERE last_name = 'Chung';
1 row updated.
SELECT salary FROM employees
WHERE last_name = 'Chung';
SALARY
----------
4000
To learn what the value was before the update, you can use the following flashback query:
SELECT salary FROM employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' DAY)
WHERE last_name = 'Chung';
SALARY
----------
3800
To revert to the earlier value, use the flashback query as the subquery of another UPDATE statement:
UPDATE employees SET salary =
(SELECT salary FROM employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' DAY)
WHERE last_name = 'Chung')
WHERE last_name = 'Chung';
1 row updated.
SELECT salary FROM employees
WHERE last_name = 'Chung';