你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle Flashback 技术总结

[日期:2011-09-11] 来源:Linux社区  作者:tianlesoftware [字体:大 中 小]
2.4.6.2.4  Specifying the Default Flashback Data Archive

            By default, the system has no default Flashback Data Archive. If you are logged on as SYSDBA, you can specify default Flashback Data Archive in either of these ways:

            默认情况下,没有default Flashback Data Archive. 当以sysdba 登陆之后,就可以指定它。

 

2.4.1 修改已经存在的Flashback Archive 为default

SQL> alter flashback archive fla1 set default;

Flashback archive altered.

 

SQL> alter flashback archive fla10 set default;

alter flashback archive fla10 set default

*

ERROR at line 1:

ORA-55605: Incorrect Flashback Archive is specified

 

如果指定的Flashback 不存在,就报错。

 

2.4.2 在创建Flashback Data Archive 时,指定default

SQL>create flashback archive default fla2 tablespace tbs1 quota 10m retention 1 year;

 

            The default Flashback Data Archive for the system is the default Flashback Data Archive for every user who does not have his or her own default Flashback Data Archive.

 

 

2.4.6.2.5  Enabling and Disabling Flashback Data Archive

            By default, flashback archiving is disabled for any table. You can enable flashback archiving for a table if you have the FLASHBACK ARCHIVE object privilege on the Flashback Data Archive to use for that table.

            默认情况下,所有表都没有启动flashback archive。

 

            To enable flashback archiving for a table, include the FLASHBACK ARCHIVE clause in either the CREATE TABLE or ALTER TABLE statement.

            In the FLASHBACK ARCHIVE clause, you can specify the Flashback Data Archive where the historical data for the table are stored. The default is the default Flashback Data Archive for the system. If you specify a nonexistent Flashback Data Archive, an error occurs.

 

            If you enable flashback archiving for a table, but AUM(automatic undo managed) is disabled, error ORA-55614 occurs when you try to modify the table.

 

            If a table has flashback archiving enabled, and you try to enable it again with a different Flashback Data Archive, an error occurs

 

            After flashback archiving is enabled for a table, you can disable it only if you either have the FLASHBACK ARCHIVE ADMINISTER system privilege or you are logged on as SYSDBA.

            To disable flashback archiving for a table, specify NO FLASHBACK ARCHIVE in the ALTER TABLE statement. (It is unnecessary to specify NO FLASHBACK ARCHIVE in the CREATE TABLE statement, because that is the default.)

 

 

示例:

2.5.1 创建table,使用默认的Flashback Data Archive      来存储历史数据

SQL> create table 安庆 (id number) flashback archive;

Table created.

 

2.5.2 创建table,使用指定的Flashback Data Archive 来存储历史数据

 

SQL> create table 怀宁 (id number) flashback archive fla1;

Table created.

 

2.5.3 对表启用Flashback archive,并使用默认的Flashback archive。

 

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.

 

2.4.6.2.6 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

 

 

            If you must use unsupported DDL statements on a table enabled for Flashback Data Archive, use the DBMS_FLASHBACK_ARCHIVE.DISASSOCIATE_FBA procedure to disassociate the base table from its Flashback Data Archive.

            To reassociate the Flashback Data Archive with the base table afterward, use the DBMS_FLASHBACK_ARCHIVE.REASSOCIATE_FBA procedure.

 

            -- 如果必须在已经启用Flashback Archive的表上执行这些不支持的DDL 操作,可以用DBMS_FLASHBACK_ARCHIVE 包将表从Flashback Data Archive 分离出来,待操作结束后在添加进去。

 

            The DBMS_FLASHBACK_ARCHIVE package contains two simple procedures for disassociation and reassociation of a Flashback Data Archive (FDA) enabled table from/with its underlying FDA respectively.

 

            在Flashback Area中,会有一张历史表记录着我们启动FA表的所有操作。 我们可以通过如下SQL 来查看他们之间的映射关系。

 

SQL> SELECT table_name,archive_table_name,status from dba_flashback_archive_tables;

 

TABLE_NAME ARCHIVE_TABLE_NAME   STATUS

---------- -------------------- --------

ANQING     SYS_FBA_HIST_78429   ENABLED

怀宁       SYS_FBA_HIST_78431   ENABLED

ORA        SYS_FBA_HIST_78448   ENABLED

DVD        SYS_FBA_HIST_78456   ENABLED

HUAINING   SYS_FBA_HIST_78464   ENABLED

QS         SYS_FBA_HIST_78472   ENABLED

FA         SYS_FBA_HIST_78484   ENABLED

 

7 rows selected.

 

            我们要执行那些不支持的DDL,就需要用dbms_flashback_archive禁用他们之间的映射关系,在操作,操作完在用该包启用他们。

 

关于dbms_flashback_archive包的使用,参考官网:

          DBMS_FLASHBACK_ARCHIVE

            http://download.Oracle.com/docs/cd/E11882_01/appdev.112/e16760/d_flashb_archive.htm#ARPLS72464

 

示例:

 

SQL> drop table 怀宁;

drop table 怀宁

           *

ERROR at line 1:

ORA-55610: Invalid DDL statement on history-tracked table

 

这个表使我们之前创建的,并启用了Flashback Archive.

 

表的分离和重新结合:

SQL> exec dbms_flashback_archive.disassociate_fba('SYS','怀宁');

PL/SQL procedure successfully completed.

 

SQL> exec dbms_flashback_archive.reassociate_fba('SYS','怀宁');

PL/SQL procedure successfully completed.

 

最后我们在分离,在drop table:

SQL> exec dbms_flashback_archive.disassociate_fba('SYS','怀宁');

PL/SQL procedure successfully completed.

 

SQL> drop table 怀宁;

drop table 怀宁

           *

ERROR at line 1:

ORA-55610: Invalid DDL statement on history-tracked table

 

drop 失败。

 

表情: - -

猜测:灵异事件。

 

google 一下,说是bug:9650074

 

9650074 ORA-55633 in Flashback data archive DDL support area

 

结果metalink 又不读开,这个网络啊。 先不研究了。

linux
相关资讯       Oracle教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款