首页 > 数据库技术 > 详细

oracle 基础--闪回技术

时间:2019-02-21 21:20:31      阅读:209      评论:0      收藏:0      [点我收藏+]

一,闪回表初探

   闪回须知:

 1 使用闪回表注意如下事项:
 2 
 3 (1)被闪回的表必须启用行移动功能
 4 
 5   SQL> alter table dept enable row movement;
 6 
 7 (2)“FLASHBACK TABLE”命令的执行者必须有“FLASHBACK ANY TABLE”系统权限或者在被闪回的表上具有“FLASHBACK”对象权限。
 8 
 9 (3)“FLASHBACK TABLE”属于DDL命令,隐式提交。
10 
11 (4)SYS用户的任何表无法使用此功能。

 

   01,闪回具体时间

   闪回须知选哟闪回的节点

   SQL> select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) from dual;

    TO_CHAR(SYSDATE,‘YY
    -------------------
    2019-02-21 21:00:02
   

   一时间的方式生成节点

    

    然后生成数据

    
    insert into dg values(11); 

SQL> select * from dg;

	ID
----------
	 1
	 2
	 3
	 4
	 5
	 6
	 7
	 8
	10

 生成一个时间点方便闪回

SQL> select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) from dual;

TO_CHAR(SYSDATE,‘YY
-------------------
2019-02-21 20:43:22

 再次插入数据

  

  闪回操作:

SQL>  flashback table dg to timestamp to_timestamp(‘2019-02-21 20:43:22‘,‘yyyy-mm-dd hh24:mi:ss‘);
 flashback table dg to timestamp to_timestamp(‘2019-02-21 20:43:22‘,‘yyyy-mm-dd hh24:mi:ss‘)
                 *
ERROR at line 1:
ORA-08185: Flashback not supported for user SYS

   发现默认不能用sys闪回,这个加入必须要的话是可以完成的,现再先不使用

  切换用户 

SQL> show user
USER is "SYS"
SQL> conn scott/123456
Connected.
SQL> show user
USER is "SCOTT"

   重新建表,插入数据查询

SQL> create table dg(id number);

Table created.

SQL> insert into dg values(1);

1 row created.

   再次闪回,

SQL> flashback table dg to timestamp to_timestamp(‘2019-02-21 20:57:08‘,‘yyyy-mm-dd hh24:mi:ss‘);
flashback table dg to timestamp to_timestamp(‘2019-02-21 20:57:08‘,‘yyyy-mm-dd hh24:mi:ss‘)
                *
ERROR at line 1:
ORA-08189: cannot flashback the table because row movement is not enabled

     发现没开启行移

SQL> alter table dg enable row movement;

Table altered.

     这次总行了吧

SQL> flashback table dg to timestamp to_timestamp(‘2019-02-21 20:57:08‘,‘yyyy-mm-dd hh24:mi:ss‘);

Flashback complete.

     再次查看数据 

SQL> select * from dg;

no rows selected

     我的天闪回有点多

    02,闪回大概时间

flashback table dg to timestamp(systimestamp-interval ‘10‘ minute);

      03,闪回SCN

    SCN查询 

01,
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    1094422

02,
SQL> select dbms_flashback.get_system_change_number() from dual;

DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER()
-----------------------------------------
				  1094447

     flashback table dg to scn 1094422;

    05,多表闪回

flashback table scott.dg,scott.t to scn 1094422

     

 

 

    

 

oracle 基础--闪回技术

原文:https://www.cnblogs.com/kingle-study/p/10415278.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!