本篇内容介绍了“Oracle闪回数据库测试方法是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
1 设置闪回目录和大小
SQL> show parameter recover
SQL> alter system set db_recovery_file_dest_size=5g;
SQL> alter system set db_recovery_file_dest='/fast_recovery';
SQL> show parameter recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /fast_recovery
db_recovery_file_dest_size big integer 5G
db_unrecoverable_scn_tracking boolean TRUE
recovery_parallelism integer 0
2 启用闪回
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
SQL> alter database flashback on;
Database altered.
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
3 查看时间
SQL> alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss';
Session altered.
SQL> select oldest_flashback_scn,oldest_flashback_time from v$flashback_database_log;
OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TI
-------------------- -------------------
1114453 2020-06-24 08:30:49
4 创建测试数据
SQL> conn cjc/cjc
SQL> create table test1 as select * from dba_objects;
SQL> select count(*) from test1;
COUNT(*)
----------
87002
5 创建闪回点
SQL> create restore point test1;
Restore point created.
6 查看闪回点
SQL> set line 200
SQL> col time for a50
SQL> col restore_point_time for a20
SQL> alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss';
SQL> select scn,time,restore_point_time,name from v$restore_point;
SCN TIME RESTORE_POINT_TIME NAME
---------- -------------------------------------------------- -------------------- ------------------------------
1114756 24-JUN-20 08.36.20.000000000 AM TEST1
7 继续插入数据
SQL> ho date
Wed Jun 24 08:39:31 CST 2020
SQL> insert into test1 select * from test1;
87002 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from test1;
COUNT(*)
----------
174004
8 删除表
SQL> drop table test1 purge;
Table dropped.
SQL> select count(*) from cjc.test1;
select count(*) from cjc.test1
*
ERROR at line 1:
ORA-00942: table or view does not exist
9 闪回数据库
---test1是之前设置的闪回点名称
SQL> conn / as sysdba
SQL> shutdown immediate
SQL> startup mount
SQL> flashback database to restore point test1;
Flashback complete.
SQL> alter database open resetlogs;
10 查看数据,数据库恢复到闪回点时刻
SQL> select count(*) from cjc.test1;
COUNT(*)
----------
87002
11 查看闪回数据
[oracle@cjcos01 flashback]$ pwd
/fast_recovery/CJCDB01/flashback
[oracle@cjcos01 flashback]$ ll -rth
total 101M
-rw-r----- 1 oracle oinstall 51M Jun 24 08:30 o1_mf_hh67ow2w_.flb
-rw-r----- 1 oracle oinstall 51M Jun 24 08:49 o1_mf_hh67osvt_.flb
12 关闭闪回,闪回日志自动删除
SQL> alter database flashback off;
Database altered.
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
[oracle@cjcos01 flashback]$ ls
“Oracle闪回数据库测试方法是什么”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!