フラッシュバック・テーブル機能

Flashback Tableの概要

  • データベースをオフラインにせずに、1つまたは複数の表を、指定した過去の時点まで迅速かつ簡単にリカバリできます。
  • Oracle Flashback Tableによって、現行の索引、トリガー、制約などの関連する属性が自動的に保持され、表がリストアされます。
  • Oracle Flashback Tableを使用すると、個々の表の内容が、任意の過去のSCNまたは時刻の状態に戻ります。
  • Oracle Flashback Tableでは、UNDO表領域の情報を使用して表がリストアされます。

Flashback Tableの前提条件

  • 表で行の移動が有効である必要があります。
  • FLASHBACK ANY TABLEシステム権限または表に対するFLASHBACKオブジェクト権限を持っている必要があります。
  • 表に対するSELECT、INSERT、DELETEおよびALTER権限を持っている必要があります。
  • 指定した目標時点またはSCNまでのFLASHBACK TABLE操作に必要な過去の時点までのUNDO情報が、UNDO表領域に保持されている必要があります。

Flashback Tableの実行

1.ALTER TABLE table ENABLE ROW MOVEMENT
2.FLASHBACK TABLE EMP TO {SCN scn_number|TIMESTAMP timestamp} [ENABLE TRIGGERS]

SQL> create table test_fb_table as select 1 id from dual;

Table created.

SQL> desc test_fb_table;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER

SQL> select * from test_fb_table;

        ID
----------
         1

SQL> select to_char(timestamp_to_scn(systimestamp)) from dual;

TO_CHAR(TIMESTAMP_TO_SCN(SYSTIMESTAMP))
----------------------------------------
2252252940376

SQL>

SQL> delete test_fb_table;

1 row deleted.

SQL> commit;

Commit complete.

SQL> select to_char(timestamp_to_scn(systimestamp)) from dual;

TO_CHAR(TIMESTAMP_TO_SCN(SYSTIMESTAMP))
----------------------------------------
2252252940431

SQL>

SQL> insert into test_fb_table values (100);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from test_fb_table;

        ID
----------
       100

SQL>

SQL> alter table test_fb_table enable row movement;

Table altered.

SQL> flashback table test_fb_table to scn 2252252940431;

Flashback complete.

SQL> select * from test_fb_table;

no rows selected

SQL>

SQL> flashback table test_fb_table to timestamp scn_to_timestamp(2252252940376);

Flashback complete.

SQL> select * from test_fb_table;

        ID
----------
         1

SQL>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License