标签:click 命名 isp amp show user 用户 connect 插入 闪回技术
闪回须知:
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
01,删除表:
SQL> drop table t 2 ; Table dropped.
1 select * from t 2 * 3 ERROR at line 1: 4 ORA-00942: table or view does not exist 5 6 7 SQL> insert into t values(2); 8 insert into t values(2) 9 * 10 ERROR at line 1: 11 ORA-00942: table or view does not exist
开始闪回:
SQL> select * from t; select * from t * ERROR at line 1: ORA-00942: table or view does not exist SQL> flashback table scott.t to before drop; Flashback complete. SQL> select * from t; ID ---------- 1 1 1 1 2
02,删除表后重新创建新的同名表闪回
1 SQL> drop table t; 2 3 Table dropped. 4 5 SQL> create table t(ID number); 6 7 Table created. 8 9 SQL> flashback table scott.t to before drop; --有同名表闪回会报错 10 flashback table scott.t to before drop 11 * 12 ERROR at line 1: 13 ORA-38312: original name is used by an existing object 14 15 16 SQL> flashback table scott.t to before drop rename to t2; --闪回的时候重新命名即可 17 18 Flashback complete. 19 20 SQL> select * from t2; 21 22 ID 23 ---------- 24 1 25 1 26 1 27 1 28 2 29 30 SQL>
标签:click 命名 isp amp show user 用户 connect 插入 闪回技术
原文地址:https://www.cnblogs.com/kingle-study/p/10415278.html