SQL_REDO
------------------------------------------------------------------------------------------------------------------------
update "SCOTT"."EMP" set "SAL" = '0' where "EMPNO" = '7900' and "SAL" = '950' and ROWID = 'AAAR3xAAEAAAACXAAL';
update "SCOTT"."EMP" set "SAL" = '0' where "EMPNO" = '7902' and "SAL" = '3000' and ROWID = 'AAAR3xAAEAAAACXAAM';
update "SCOTT"."EMP" set "SAL" = '0' where "EMPNO" = '7934' and "SAL" = '1300' and ROWID = 'AAAR3xAAEAAAACXAAN';
14 rows selected.
SQL>
6.7、现在我需要将数据还原���去,那么就需要执行误操作的相反的操作。(通过undo来查出对应的反向语句)
select sql_undo from v$logmnr_contents where seg_name='EMP';
如:
SQL> select sql_undo from v$logmnr_contents where seg_name='EMP';
SQL_UNDO
------------------------------------------------------------------------------------------------------------------------
update "SCOTT"."EMP" set "SAL" = '800' where "EMPNO" = '7369' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAA';
update "SCOTT"."EMP" set "SAL" = '1600' where "EMPNO" = '7499' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAB';
update "SCOTT"."EMP" set "SAL" = '1250' where "EMPNO" = '7521' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAC';
update "SCOTT"."EMP" set "SAL" = '2975' where "EMPNO" = '7566' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAD';
update "SCOTT"."EMP" set "SAL" = '1250' where "EMPNO" = '7654' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAE';
update "SCOTT"."EMP" set "SAL" = '2850' where "EMPNO" = '7698' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAF';
update "SCOTT"."EMP" set "SAL" = '2450' where "EMPNO" = '7782' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAG';
update "SCOTT"."EMP" set "SAL" = '3000' where "EMPNO" = '7788' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAH';
update "SCOTT"."EMP" set "SAL" = '5000' where "EMPNO" = '7839' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAI';
update "SCOTT"."EMP" set "SAL" = '1500' where "EMPNO" = '7844' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAJ';
update "SCOTT"."EMP" set "SAL" = '1100' where "EMPNO" = '7876' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAK';
SQL_UNDO
------------------------------------------------------------------------------------------------------------------------
update "SCOTT"."EMP" set "SAL" = '950' where "EMPNO" = '7900' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAL';
update "SCOTT"."EMP" set "SAL" = '3000' where "EMPNO" = '7902' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAM';
update "SCOTT"."EMP" set "SAL" = '1300' where "EMPNO" = '7934' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAN';
14 rows selected.
SQL>
6.8、获取到反向操作语句后,再将反向操作语句重新执行一遍
update "SCOTT"."EMP" set "SAL" = '800' where "EMPNO" = '7369' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAA';
update "SCOTT"."EMP" set "SAL" = '1600' where "EMPNO" = '7499' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAB';
update "SCOTT"."EMP" set "SAL" = '1250' where "EMPNO" = '7521' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAC';
update "SCOTT"."EMP" set "SAL" = '2975' where "EMPNO" = '7566' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAD';
update "SCOTT"."EMP" set "SAL" = '1250' where "EMPNO" = '7654' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAE';
update "SCOTT"."EMP" set "SAL" = '2850' where "EMPNO" = '7698' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAF';
update "SCOTT"."EMP" set "SAL" = '2450' where "EMPNO" = '7782' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAG';
update "SCOTT"."EMP" set "SAL" = '3000' where "EMPNO" = '7788' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAH';
update "SCOTT"."EMP" set "SAL" = '5000' where "EMPNO" = '7839' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAI';
update "SCOTT"."EMP" set "SAL" = '1500' where "EMPNO" = '7844' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAJ';
update "SCOTT"."EMP" set "SAL" = '1100' where "EMPNO" = '7876' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAK';
update "SCOTT"."EMP" set "SAL" = '950' where "EMPNO" = '7900' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAL';
update "SCOTT"."EMP" set "SAL" = '3000' where "EMPNO" = '7902' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAM';
update "SCOTT"."EMP" set "SAL" = '1300' where "EMPNO" = '7934' and "SAL" = '0' and ROWID = 'AAAR3xAAEAAAACXAAN';
6.9、查询最后结果显示,数据全部找回
SQL> select sal from scott.emp;