FLASHBACK TABLE闪回表

一、
查看某一张表的的行移动功能是不是开启的
SQL> select row_movement from user_tables where table_name = 'ZSX';
ROW_MOVE
--------
DISABLED

二、
启动某张表的行移动功能
SQL> alter table zsx enable row movement;
Table altered.
SQL> select row_movement from user_tables where table_name = 'ZSX';
ROW_MOVE
--------
ENABLED

三、
禁止某张表的行移动功能
SQL> alter table zsx disable row movement;
Table altered.
SQL> select row_movement from user_tables where table_name = 'ZSX';
ROW_MOVE
--------
DISABLED

四、
实例:
将一张表闪回到过去的某个时间点,主要是用于某张表错误的更新
1、
启动表的行移动功能
SQL> alter table zsx enable row movement;
2、
查询表中的数据
SQL> select * from zsx;
        ID
----------
         1
3、
查询现在的SCN
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
     692434
4、
删除表中的数据
SQL> delete from zsx;
1 row deleted.
SQL> commit;
Commit complete.
5、
现在再次查看表中的数据
SQL> select * from zsx;
no rows selected
6、
闪回这张表到scn692434
SQL> flashback table zsx to scn 692434;
Flashback complete.
7、
再次查询这张表,如果有数据,就证明闪回生效了
SQL> select * from zsx;
        ID
----------
         1

8、

还可以闪回一张表到某个时间点:

flashback table zsx to  timestamp to_timestamp('2016-09-09 09:09:09', 'YYYY-MM-DD HH24:MI:SS');

9、

To flash back a table to an earlier SCN or timestamp, you must have either the FLASHBACK object privilege on the table or the FLASHBACK ANY TABLEsystem privilege. In addition, you must have the SELECTINSERTDELETE, and ALTER object privileges on the table.

你可能感兴趣的:(FLASHBACK TABLE闪回表)