zoukankan      html  css  js  c++  java
  • Oracle恢复删除数据

      可以通过SCN和时间戳两种方法来恢复。

    一、通过SCN恢复删除且已经提交的数据

    • 查询当前SCN
    select current_scn from v$database; 

      如图:

    • 缩小范围进行查询

      查询到当前的SCN为14543776308552,查询当前SCN之前的SCN对应的表数据。

    select * from 表名 as of scn 14543776308550; -- 确定删除的数据是否存在,如存在,则恢复数据;否则继续缩小scn号
    • 恢复数据
    flashback table 表名 to scn 14543776308550;

    二、通过时间戳进行恢复

    • 查询当前的系统时间
    select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') from dual;
    • 查询删除数据时间点之前的数据
    select * from 表名 as of timestamp to_timestamp('2018-02-13 15:48:00', 'yyyy-mm-dd hh24:mi:ss'); -- 如果不是,则继续缩小时间范围
    • 恢复数据
    flashback table 表名 to timestamp to_timestamp('2018-02-13 15:48:00','yyyy-mm-dd hh24:mi:ss');

       备注:如果执行恢复数据SQL出现错误,可以执行: alter table 表名 enable row movement; //允许更改时间戳

  • 相关阅读:
    STM32概述
    对xlslib库与libxls库的简易封装
    Makefile.am编写规则
    linux下使用autoconf制作Makefile
    python 登录三次禁止登录
    Linux -- gpasswd
    Linux -- userdel
    Linux -- groupmod
    Linux -- groupadd
    Linux -- passwd
  • 原文地址:https://www.cnblogs.com/BillyYoung/p/BillyYang_oracle.html
Copyright © 2011-2022 走看看