闪回须知:
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
原文:https://www.cnblogs.com/kingle-study/p/10415278.html