1.测试表
SQL> select * from t;
X NAME
---------- ----------
1 a
2 b
3 b
4 d
2.查下当前SCN
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
968257
3.删除一行并提交
SQL> delete from t where x=1;
已删除 1 行。
SQL> commit;
提交完成。
4.通过scn闪回表
SQL> flashback table t to scn 968257;
flashback table t to scn 968257
*
第 1 行出现错误:
ORA-08189: 因为未启用行移动功能, 不能闪回表
闪回表要先启用行移动
SQL> alter table t enable row movement;
表已更改。
SQL> flashback table t to scn 968257;
闪回完成。
SQL> select * from t;
X NAME
---------- ----------
1 a
2 b
3 b
4 d
5.通过时间闪回表
20:22:33 SQL> select * from t;
X NAME
---------- ----------
1 a
2 b
3 b
4 d
已用时间: 00: 00: 00.01
20:22:37 SQL> delete from t where x=2;
已删除 1 行。
已用时间: 00: 00: 00.01
20:22:56 SQL> commit;
提交完成。
已用时间: 00: 00: 00.00
20:25:48 SQL> flashback table t to timestamp to_date('2014-7-5 20:22:33','yyyy-mm-dd hh24:mi:ss');
闪回完成。
已用时间: 00: 00: 00.84
20:26:52 SQL> select *from t;
X NAME
---------- ----------
1 a
2 b
3 b
4 d
已用时间: 00: 00: 00.00
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26937943/viewspace-1210459/
,如需转载,请注明出处,否则将追究法律责任。