zoukankan      html  css  js  c++  java
  • oracle恢复被删除的数据

    两种方法:(1)、scn方法   (2)、时间戳法

    (1)、scn方法(通过scn恢复删除数据的sql语法)

      a、获取当前数据库的scn号

        select  current_scn  from  v$database;

        查询到的scn号为:  

      b、查询当前scn号之前的scn号

        select  * from  表名  as  of  scn  scn号(确定删除的数据是否存在,如果存在则恢复数据; 如果不存在,则继续缩小scn号)

      c、恢复删除且已经提交的数据  

        flashback  table  表名  to  scn   scn号

     (2)、时间戳方法

      a、查询当前系统的时间  

        select  to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss')  from  dual

      b、select  *  from  表名   as  of  timestamp  to_timestamp('2020-02-02 15:22:00', 'yyyy-mm-dd  hh24:mi:ss')(如果不是继续缩小范围)

     (3)、恢复删除且已提交的数据

       --开启行移动功能(解决执行一下语句报错的问题)

         alter  table  表名  enable  row   movement;

       --恢复某个时间点的数据

         flashback  table  表名  to  timestamp  to_timestamp ('2020-02-02 15:21:00', 'yyyy-mm-dd hh24:mi:ss');

       --关闭行移动功能

        alter table  表名  disable  row  movement;

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

    --开启行移动功能(解决执行以下语句报错问题)

    alter   alter  表名   enable   row  movement;

    --恢复某个时间点的数据

    flashback  table  表名  to   timestamp to_timestamp ('2020-02-02  12:12:00', 'yyyy-mm-dd  hh24:mi:ss')   (保证此时间为删除操作之前的操作)

    --关闭行移动功能

    alter  alter  表名  disable  row   movement;

    参考:https://www.cnblogs.com/xielong/p/11239939.html

  • 相关阅读:
    validFrom不通过submit按钮来触发表单验证
    微信小程序组件开发
    css3 单行文字溢出,多行文字溢出
    表格布局
    对象设置默认属性
    按钮样式
    判断一个json是否为空
    vue高仿饿了么(三)
    Win10 用IE打开网址默认跳转到Edge如何解决?
    VMware虚拟机安装Win11正式版
  • 原文地址:https://www.cnblogs.com/wongzzh/p/13435366.html
Copyright © 2011-2022 走看看