Flashback data archive相比flashback query则更进了一步。Flashback data archive不再直接使用UNDO信息获得历史数据,而是把历史数据保存在一个track table里。Oracle新增加了一个后台进程fbda,此进程每隔一段时间(通常是5分钟)把UNDO中的历史数据信息加到track table里。如果表上开启了flashback archive功能,则Oracle先给事务产生的UNDO信息做标记,直到被标记的UNDO信息加到track table后,此UNDO空间才能被重用。
Flashback data archive采用压缩方式存储历史数据,以减小空间占用。同时flashback data archive采用range分区方式对track table表进行分区。track table表上没有索引,用户可根据需要对track table增加索引。
2.2 Altering a Flashback Data Archive
With the ALTER FLASHBACK ARCHIVE statement, you can:
-- 使用alter flashback archive 可以修改如下内容:
(1)Change the retention time of a Flashback Data Archive
(2)Purge some or all of its data
(3)Add, modify, and remove tablespaces
Note:
Removing all tablespaces of a Flashback Data Archive causes an error.
If you are logged on as SYSDBA, you can also use the ALTER FLASHBACK ARCHIVE statement to make a specific file the default Flashback Data Archive for the system.
-- 不能移除Flashback Data Archive里的所有表空间。 否则报错。 如果用sysdba 登陆,可以修改默认的Flashback archive。
示例:
2.2.1 将Flashback Data Archive 修改为default FA
先用我们具有flashback archive administer 权限的用户试试:
SQL> conn dvd/dvd;
Connected.
SQL> alter flashback archive fla1 set default;
alter flashback archive fla1 set default
*
ERROR at line 1:
ORA-55611: No privilege to manage default Flashback Archive
报错,没有权限,用sysdba 测试成功:
SQL> conn / as sysdba;
Connected.
SQL> alter flashback archive fla1 set default;
Flashback archive altered.
注意一点,只能有一个默认的Flashback archive.
SQL> select flashback_archive_name name, status from dba_flashback_archive;
NAME STATUS
---------- -------
FLA1 DEFAULT
FLA2
当前默认的Flashback Archive 是FLA1,我们将默认改成FLA2,在查看:
SQL> alter flashback archive fla2 set default;
Flashback archive altered.
SQL> select flashback_archive_name name, status from dba_flashback_archive;
NAME STATUS
---------- -------
FLA1
FLA2 DEFAULT
SQL> alter table dave flashback archive;
Table altered.
2.5.4 禁用表的Flashback Archive
SQL> alter table dave no flashback archive;
Table altered.
2.5.5 对table 启用Flashback archive,并指定Flashaback Archive 区。
SQL> alter table dave flashback archive fla1;
Table altered.
DDL Statements on Tables Enabled for Flashback Data Archive
Flashback Data Archive supports many DDL statements, including some that alter the table definition or move data. For example:
--启动Flashback Data Archive的表支持以下的DDL 操作
(1)ALTER TABLE statement that does any of the following:
1)Adds, drops, renames, or modifies a column
2)Adds, drops, or renames a constraint
3)Drops or truncates a partition or subpartition operation
(2)TRUNCATE TABLE statement
(3)RENAME statement that renames a table
Some DDL statements cause error ORA-55610 when used on a table enabled for Flashback Data Archive. For example:
-- 启动Flashback Data Archive的表上的一些DDL 操作可能触发ORA-55610的错误,这些DDL 如下:
(1)ALTER TABLE statement that includes an UPGRADE TABLE clause, with or without an INCLUDING DATA clause
(3)ALTER TABLE statement that moves or exchanges a partition or subpartition operation
(3)DROP TABLE statement