Flashback Tips

The following tips and restrictions apply to using flashback features.

Flashback Tips – Performance
  • For better performance, generate statistics on all tables involved in a Flashback Query by using the DBMS_STATS package, and keep the statistics current. Flashback Query always uses the cost-based optimizer, which relies on these statistics.

    为了获得更好的性能,用dbms_stats收集统计所有在闪回查询中要应用的表并且保持这些信息最新。闪回查询总是使用基于成本的优化,这依赖于这些统计数据。

  • The performance of a query into the past depends on how much undo data must be accessed. For better performance, use queries to select small sets of past data using indexes, not to scan entire tables. If you must do a full table scan, consider adding a parallel hint to the query.

    一个查询到过去的取决于多少的undo数据需要访问。为了获得更好的性能,利用 索引来查询。如果你必须做一次全表扫描,可以考虑添加一个并行提示查询

  • The performance cost in I/O is the cost of paging in data and undo blocks that are not already in the buffer cache. The performance cost in CPU use is the cost of applying undo information to affected data blocks. When operating on changes in the recent past, flashback features essentially CPU bound.

    在I/O性能成本是分布数据的成本和undo块不是已经在缓冲区高速缓存块。在CPU使用性能成本将undo信息的数据块的成本的影响。操作时,在最近的过去的变化,闪回功能基本上CPU绑定。

  • Use index structures for Flashback Version Query: the database keeps undo data for index changes as well as data changes. Performance of index lookup-based Flashback Version Query is an order of magnitude faster than the full table scans that are otherwise needed.

    使用索引结构的闪回版本查询:数据库保存索引及数据库在 undo中。索引查找基于性能的闪回版本查询是一个数量级的速度比其他需要全表扫描要快。

  • In a Flashback Transaction Query, the type of the xid column is RAW(8). To take advantage of the index built on the xid column, use the HEXTORAW conversion function: HEXTORAW(xid).

    闪回事务查询 中,列名xid属性为RAW,利用 xid列建立索引,可以用hextoraw函数 转换

  • Flashback Query against a materialized view does not take advantage of query rewrite optimizations.

    闪回查询物化视图不利于查询重写优化

    See Also:

    Oracle Database Performance Tuning Guide

Flashback Tips – General
  • Use the DBMS_FLASHBACK package or other flashback features? Use ENABLE/DISABLE calls to the DBMS_FLASHBACK package around SQL code that you do not control, or when you want to use the same past time for several consecutive queries. Use Flashback Query, Flashback Version Query, or Flashback Transaction Query for SQL that you write, for convenience. A Flashback Query, for example, is flexible enough to do comparisons and store results in a single query.

  • To obtain an SCN to use later with a flashback feature, use DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER.

  • You can compute or retrieve a past time to use in a query by using a function return value as a timestamp or SCN argument. For example, you can perform date and time calculations by adding or subtracting an INTERVAL value to the value of the SYSTIMESTAMP function.

  • You can query locally or remotely (Flashback Query, Flashback Version Query, or Flashback Transaction Query). for example here is a remote Flashback Query:

    (SELECT * FROM employees@some_remote_host AS OF
    TIMESTAMP (SYSTIMESTAMP - INTERVAL '60' MINUTE);
    闪回查询,闪回事物查询,闪回版本查询可以用于本地或者是远程
  • To ensure database consistency, always perform a COMMIT or ROLLBACK operation before querying past data.

    为了保证数据库的一致性,始终执行COMMIT或ROLLBACK操作前查询之前的数据。

  • Remember that all flashback processing is done using the current session settings, such as national language and character set, not the settings that were in effect at the time being queried.

    记住,所有的闪回操作是通过使用当前会话的设置,如国家语言和字符集,而不受当时被查询的影响。

  • Some DDLs that alter the structure of a table, such as drop/modify column, move table, drop partition, and truncate table/partition, invalidate any existing undo data for the table. It is not possible to retrieve data from a point earlier than the time such DDLs were executed. Trying such a query results in error ORA-1466. This restriction does not apply to DDL operations that alter the storage attributes of a table, such as PCTFREE, INITRANS, and MAXTRANS.

    一些操作,改变表的结构,如删除/修改列的表,移动,删除分区,并截断表/分区,对于这张表上的任意undo数据是无效的。不可能从早于这个时间点恢复如dll操作,如果出现此操作,将会报ora-1466错误。该限制不适用于DDL操作变更表的存储属性,如pctfree,initrans,和maxtrans。

  • Use an SCN to query past data at a precise time. If you use a timestamp, the actual time queried might be up to 3 seconds earlier than the time you specify. Internally, Oracle Database uses SCNs; these are mapped to timestamps at a granularity of every 3 seconds.

    使用一个SCN查询过去的数据在一个精确的时间。如果你使用一个时间戳,实时查询可能长达3秒,比您指定的时间。在内部,Oracle数据库使用SCN;这些被映射到时间戳的粒度为每3秒。

    For example, assume that the SCN values 1000 and 1005 are mapped to the times 8:41 and 8:46 AM respectively. A query for a time between 8:41:00 and 8:45:59 AM is mapped to SCN 1000; a Flashback Query for 8:46 AM is mapped to SCN 1005.

    例如,假设指定SCN值1000和1005映射到次41 8:46上午和8点46。一种8:41:00和8:45:59是之间的时间查询映射到SCN 1000;一种是8:46闪回查询映射到SCN 1005。

    Due to this time-to-SCN mapping, if you specify a time that is slightly after a DDL operation (such as a table creation) the database might actually use an SCN that is just before the DDL operation. This can result in error ORA-1466.

    在时间和scn映射上,如果 你指定的时间在DDL操作之后实际使用的scn在DDL操作之前,那么有可能 结果会产生ora-1466操作

  • You cannot retrieve past data from a V$ view in the data dictionary. Performing a query on such a view always returns the current data. You can, however, perform queries on past data in other views of the data dictionary, such as USER_TABLES.

    你不能从一个视图在数据字典视图检索历史数据。对视图执行的查询是返回的当前数据。你可以,但是,执行对数据字典视图查询其他过去的数据,如user_tables

ORACLE 10G 闪回建议的更多相关文章

  1. 【Oracle】闪回技术

    1.闪回技术描述 2.数据库的准备: --undo表空间要设置成AUTO,设置合适的保存时间.undo表空间: SYS@ENMOEDU> show parameter undo NAME TYP ...

  2. Oracle Flashback 闪回

    Oracle 的闪回技术是一种数据恢复技术,仅能对用户逻辑错误进行恢复, 闪回针对的是提交commit的事务,没有提交的事务,使用rollback 1.闪回版本查询 Flashback Version ...

  3. Oracle的闪回特性之恢复truncate删除表的数据

    Oracle的闪回特性之恢复truncate删除表的数据 SQL> show parameter flashback NAME                                 T ...

  4. oracle的闪回功能

    ORACLE的闪回功能: navicat 执行删改语句 不用提交直接执行? 感觉很恐怖? 今天一不下心手一滑 选错 结果把数据库的字段全改了 很慌 然后发现 oracle 有一个闪回功能 专门用来补天 ...

  5. [Oracle]Oracle的闪回归档

    Oracle的闪回归档 场景需求,由于管理数据库的一些核心表,在实施初期会有人为误删除的问题.Oracle 11gR2提供了闪回归档的特性,可以保证不用RMAN来恢复误删除的数据.实践如下: 1.创建 ...

  6. Oracle 六闪回技术,flashback

    Flashback 技术基于Undo segment基于内容的, 因此,限制UNDO_RETENTON参数. 要使用flashback 特征,您必须启用自己主动撤销管理表空间. 在Oracle 11g ...

  7. oracle之三闪回flashback

    闪回 flashback 5.1 flashback 的功能:1)利用undo data回溯或撤销提交的数据,2)flashback log 使database 可以恢复到过去某个时间点,可以作为不完 ...

  8. Oracle的闪回操作

    Oracle10g中引入了闪回技术,但这并不意味着所有的表都能闪回成功,当没有足够的磁盘空间,Oracle将使用回收站中的磁盘空间,而且位图连接索引和引用完整性约束也不受回收站的保护. recycle ...

  9. Oracle 的闪回技术 --flashback

    SQL Fundamentals: 表的创建和管理 如何开启数据库闪回? SQL> shutdown immediate; ORA-01109: database not open Databa ...

随机推荐

  1. 关于oracle的rowid

    oracle数据库中表的每一行(元组)均有一个rowid,它是数据的详细地址,通过rowid,oracle可以快速的定位某行具体的数据的位置. ROWID可以分为物理rowid和逻辑rowid两种.普 ...

  2. Python的平凡之路(9)

    一.Paramiko模块练习 1. Paramiko模块介绍 Paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接   2 .SSHclie ...

  3. EF 自定义校验设置和捕获异常

    一.定义 public class MyItem: IValidatableObject { [Key] public long Id { get; set; } [Range(0, 100, Err ...

  4. angular插件合集

    图片视频类 angular-maxonry 图片墙效果插件,可以将图片组织成类似于瀑布流的效果,依赖于jQuery.imageloaded和Masonry angular-deckgrid 另一个照片 ...

  5. Python 决策树的构造

    上一节我们学习knn,kNN的最大缺点就是无法给出数据的内在含义,而使用决策树处理分类问题,优势就在于数据形式非常容易理解. 决策树的算法有很多,有CART.ID3和C4.5等,其中ID3和C4.5都 ...

  6. ZFIR054-现金流量表

    *********************************************************************** * Title : ZFIR102 * * Applic ...

  7. LeetCode() Word Search II

    超时,用了tire也不行,需要再改. class Solution { class TrieNode { public: // Initialize your data structure here. ...

  8. ping不通 www.baidu.com 163.com

    可以试试这个命令:netsh winsock reset ping不通,但是可以上网,原因有以下几个: 1.远程主机禁止ping 2.firewall禁止ping,icmp 3.dns解析有问题 fr ...

  9. npm以及gulp相关操作

    在工作流相关的第一篇博客中,我们安装了nodejs的环境,那么nodejs自带的npm是一个功能十分强大的管理器,它已经不仅仅是局限于nodejs的版本管理器了,那么当现在我们可以通过npm来下载我们 ...

  10. 【java消息格式化】使用MessageFormat进行消息格式化

    主要介绍了: 消息格式化的基本使用: 格式化:匹配数字: 格式化:匹配日期: 格式化:匹配时间: 格式化:多次匹配: MessageFormat用来格式化一个消息,通常是一个字符串.MessageFo ...