zoukankan      html  css  js  c++  java
  • 【Oracle】闪回表

    语法:

    FLASHBACK TABLE [ schema. ] table [, [ schema. ] table ]...

    TO { { { SCN | TIMESTAMP } expr| RESTORE POINT restore_point}

    [ { ENABLE | DISABLE } TRIGGERS ]| BEFORE DROP [ RENAME TO table ]} ;

    注  flashback table  为 ddl

     

    1.创建测试表T1,并插入数据

    SCOTT@lgr> create table t1 (x number(2),d date);

     

    Table created.

     

    SCOTT@lgr> insert into t1 (x) values(1);

     

    1 row created.

     

    SCOTT@lgr> insert into t1 values(2,sysdate);

     

    1 row created.

     

    SCOTT@lgr> commit;

     

    Commit complete.

     

    SCOTT@lgr> select * from t1;

     

             X D

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

             1

             2 2017-02-19,10:53:41

     

    2.记录当前的时间

    SCOTT@lgr> select sysdate from dual;

     

    SYSDATE

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

    2017-02-19,10:54:49

     

    3.删除T1表中的一条数据

    SCOTT@lgr> delete t1 where x=2;

     

    1 row deleted.

     

    SCOTT@lgr> commit;

     

    Commit complete.

     

    SCOTT@lgr> select * from t1;

     

             X D

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

             1

     

    4.此时对表进行闪回,会出现错误。原因很明显,因为表T1没有开启行移动

    SCOTT@lgr> flashback table t1 to timestamp to_date('2017-02-19,10:54:49','yyyy-mm-dd,hh24:mi:ss');

    flashback table t1 to timestamp to_date('2017-02-19,10:54:49','yyyy-mm-dd,hh24:mi:ss')

                    *

    ERROR at line 1:

    ORA-08189: cannot flashback the table because row movement is not enabled

     

    SCOTT@lgr> select table_name,row_movement from user_tables where table_name='T1';

     

    TABLE_NAME                     ROW_MOVE

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

    T1                             DISABLED

     

    5.对表T1开启行移动

    SCOTT@lgr> alter table t1 enable row movement;

     

    Table altered.

     

    6.对表T1进行基于时间点的闪回操作

    SCOTT@lgr> flashback table t1 to timestamp to_date('2017-02-19,10:54:49','yyyy-mm-dd,hh24:mi:ss');

     

    Flashback complete.

     

    SCOTT@lgr> select * from t1;

     

             X D

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

             1

             2 2017-02-19,10:53:41

  • 相关阅读:
    C#生成图形验证码
    飞刀软件官网正式开通
    IIS7或者IIS7.5部署MVC项目时出现404错误
    office编程必不可少 [转]
    C# 利用 HttpWebRequest 和 HttpWebResponse 模拟登录有验证码的网站
    console方便用法
    24个解决实际问题的ES6代码段
    遍历对象的属性和对象的值
    前端图片处理
    Vue团队代码规范
  • 原文地址:https://www.cnblogs.com/NextAction/p/7366656.html
Copyright © 2011-2022 走看看