Oracle官方并不推荐在数据库物理结构发生改变的情况下进行Flashback,但有些特殊情况。例如项目上线时出现异常需要快速的回滚到表空间被删除之前的操作。那么flashback tablespace想比于进行全库的restore和recover能更快速的满足要求,减少宕机时间。
具体演示
SQL> create tablespace tt datafile '/home/oracle/tt.dbf' size 10m;
Tablespace created.
SQL> conn hr/hr;
Connected.
SQL> create table t1 tablespace tt as select * from hr.employees;
Table created.
SQL> conn / as sysdba
Connected.
SQL> create restore point aa guarantee flashback database;
Restore point created.
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
854968
SQL> alter tablespace tt offline;
Tablespace altered.
SQL> drop tablespace tt including contents and datafiles;
Tablespace dropped.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1874841600 bytes
Fixed Size 1337268 bytes
Variable Size 1073743948 bytes
Database Buffers 788529152 bytes
Redo Buffers 11231232 bytes
Database mounted.
SQL> flashback database to restore point aa;
Flashback complete.
SQL> alter database open resetlogs;
Database altered.
SQL> col error for a20
SQL> select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- ------- -------------------- ---------- ---------
6 OFFLINE OFFLINE FILE NOT FOUND 0
6 rows selected.
SQL> col name for a60
SQL> select name, file#, status from v$datafile;
NAME FILE# STATUS
------------------------------------------------------------ ---------- -------
/u01/app/oracle/oradata/PROD/system01.dbf 1 SYSTEM
/u01/app/oracle/oradata/PROD/sysaux01.dbf 2 ONLINE
/u01/app/oracle/oradata/PROD/undotbs01.dbf 3 ONLINE
/u01/app/oracle/oradata/PROD/users01.dbf 4 ONLINE
/u01/app/oracle/oradata/PROD/example01.dbf 5 ONLINE
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/UNNAMED00006 6 OFFLINE
6 rows selected.
SQL> alter database create datafile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/UNNAMED00006' as '/home/oracle/tt.dbf';
Database altered.
SQL> select name, file#, status from v$datafile;
NAME FILE# STATUS
------------------------------------------------------------ ---------- -------
/u01/app/oracle/oradata/PROD/system01.dbf 1 SYSTEM
/u01/app/oracle/oradata/PROD/sysaux01.dbf 2 ONLINE
/u01/app/oracle/oradata/PROD/undotbs01.dbf 3 ONLINE
/u01/app/oracle/oradata/PROD/users01.dbf 4 ONLINE
/u01/app/oracle/oradata/PROD/example01.dbf 5 ONLINE
/home/oracle/tt.dbf 6 OFFLINE
6 rows selected.
SQL> recover datafile 6;
ORA-00279: change 854654 generated at 11/15/2015 21:49:06 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/PROD/archivelog/2015_11_15/o1_mf_1_7_c4k3f1g
g_.arc
ORA-00280: change 854654 for thread 1 is in sequence #7
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
Log applied.
Media recovery complete.
SQL> alter database datafile 6 online;
Database altered.
SQL> desc hr.t1;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYEE_ID NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
SQL> select count(*) from hr.t1;
COUNT(*)
----------
107
相关日志
Completed: ALTER DATABASE MOUNT
Sun Nov 15 21:50:17 2015
flashback database to restore point aa #flashback database
Flashback Restore Start
Flashback: created tablespace #7: 'TT' in the controlfile.
Flashback: created OFFLINE file 'UNNAMED00006' for tablespace #7 in the controlfile.
Filename was:
'/home/oracle/tt.dbf' when dropped.
File will have to be restored from a backup and recovered.
Flashback Restore Complete
Flashback Media Recovery Start
Serial Media Recovery started
Recovery of Online Redo Log: Thread 1 Group 1 Seq 7 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/PROD/redo01.log
Incomplete Recovery applied until change 854954 time 11/15/2015 21:49:24
Flashback Media Recovery Complete
Completed: flashback database to restore point aa
alter database open resetlogs
Archived Log entry 1 added for thread 1 sequence 7 ID 0x10d32bc0 dest 1:
Archived Log entry 2 added for thread 1 sequence 5 ID 0x10d32bc0 dest 1:
Sun Nov 15 21:50:28 2015
Archived Log entry 3 added for thread 1 sequence 6 ID 0x10d32bc0 dest 1:
RESETLOGS after incomplete recovery UNTIL CHANGE 854954
Resetting resetlogs activation ID 282274752 (0x10d32bc0)
Sun Nov 15 21:50:35 2015
Setting recovery target incarnation to 3
......................................................
Dictionary check beginning
File #6 is offline, but is part of an online tablespace.
data file 6: '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/UNNAMED00006' #发现datafile 6 offline
Dictionary check complete
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
......................................................
alter database create datafile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/UNNAMED00006' as '/home/oracle/tt.dbf' #rename datafile 6
Completed: alter database create datafile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/UNNAMED00006' as '/home/oracle/tt.db
.................................
ALTER DATABASE RECOVER datafile 6 #recover datafile 6
Media Recovery Start
Serial Media Recovery started
Media Recovery start incarnation depth : 1, target inc# : 3, irscn : 854954
ORA-279 signalled during: ALTER DATABASE RECOVER datafile 6 ...
Sun Nov 15 21:52:57 2015
ALTER DATABASE RECOVER CONTINUE DEFAULT
Media Recovery Log /u01/app/oracle/flash_recovery_area/PROD/archivelog/2015_11_15/o1_mf_1_7_c4k3f1gg_.arc
Recovery of Online Redo Log: Thread 1 Group 1 Seq 1 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/PROD/redo01.log
Media Recovery Complete (PROD)
Completed: ALTER DATABASE RECOVER CONTINUE DEFAULT
alter database datafile 6 online
Completed: alter database datafile 6 online
本文原创,转载请注明出处,作者
如有错误,欢迎指正
邮箱:czmcj@163.com
相关推荐
ORACLE flashback database测试,主要进行ORACLE flashbackup 闪回整个数据库的实现。
### Oracle Flashback 技术详解 #### 一、概述 Oracle Flashback 技术是一种能够帮助用户恢复数据库至某一特定时间点的技术。该技术利用了Undo Segment中的数据,因此受到`UNDO_RETENTION`参数的影响。为了启用...
ORACLE FLASHBACK 综述 Oracle Flashback 是 Oracle 数据库中的一种功能,允许用户快速地恢复数据库到以前的状态,从而避免了由于操作失误或用户错误带来的问题。下面是 Oracle Flashback 的知识点。 1. Oracle ...
Oracle Flashback技术是Oracle数据库提供的一种强大的数据恢复和时间旅行功能,它允许用户查看和恢复到数据库的某个历史状态,而无需依赖传统的备份和恢复过程。这一特性在处理误删除、错误更新或需要查看历史数据时...
Oracle Flashback 特性 Oracle Flashback 是 Oracle 数据库中的一种功能强大的特性,可以让用户快速地恢复到过去的某个时间点,查看过去的数据状态,或者是回滚到某个特定的事务状态。Flashback 特性可以分为三个...
Oracle Flashback技术是Oracle数据库提供的一种强大的数据恢复和历史数据查询功能,它允许用户恢复到数据库的某个历史状态,或者查询过去的某个时刻的数据。这项技术的核心是基于Undo Segment中的信息,Undo Segment...
在Oracle 10g中,Flashback技术包含了多个组件,如Flashback Database、Flashback Drop、Flashback Query(包括Flashback Query、Flashback Version Query和Flashback Transaction Query)以及Flashback Table。...
Oracle Flashback技术是数据库管理系统中的一种高级特性,它允许用户恢复到数据库的某个历史状态,无需进行复杂的备份和恢复操作。这项技术主要基于事务日志和快照来实现,为数据库管理员提供了极大的便利,尤其在...
Oracle Flashback技术是Oracle数据库提供的一种高级数据恢复机制,它允许用户恢复到数据库的某个历史状态,无需回滚日志或还原备份。在医院数据恢复中,这一特性尤为重要,因为医院业务的连续性和数据完整性至关重要...
### Oracle Flashback技术详解 #### 一、概述 Oracle Flashback技术是一种强大的数据恢复机制,它可以帮助用户在遇到数据丢失或损坏的情况下恢复到之前的某个时间点。这项技术基于Undo Segment中的内容,允许用户...
Oracle的Flashback技术是数据库管理系统中的一个重要特性,它允许用户恢复到数据库的某个历史状态,无需依赖传统的备份和恢复过程。这项技术对于处理误操作、临时数据错误或进行时间点恢复非常有用。在本篇文章中,...
Oracle 闪回特性 FLASHBACK & RECYCLEBIN Flashback 系列是 Oracle 数据库中的一组功能强大且实用的闪回机制,旨在帮助数据库管理员和开发者快速恢复数据库中的各种对象,包括表、数据、事务等。Flashback 系列的...
"Oracle 闪回(Flashback)技术" Oracle 闪回(Flashback)技术是 Oracle 数据库提供的一系列人为错误更正技术,用于快速恢复逻辑误操作。闪回技术从 Oracle 9i 版本开始,逐步发展到 Oracle 11g 版本,成为数据库...
### Oracle 10g Flashback 数据恢复功能详解 Oracle 10g 引入了强大的 Flashback 技术,这是一系列旨在帮助管理员和开发者在出现数据丢失或损坏时能够快速恢复数据的功能集合。该技术从 Oracle 9i 开始引入,并在 ...
FLASHBACK DATABASE flashback data1base闪回到过去的某一时刻 闪回点之后的所有工作都将丢失 必须使用resetlogs创建新的场景并打开数据库(一旦resetlogs之后,将不能再闪回至resetlogs之前的时间点) .......
### Oracle Flashback 家族详解 #### 一、概述 Oracle Flashback 技术是一种强大的数据恢复机制,它允许用户将数据库、表甚至是查询结果回滚到过去某个时间点的状态,而无需传统的备份和恢复过程。这一技术在...
CREATE FLASHBACK ARCHIVE flar1 TABLESPACE mytest RETENTION 1 YEAR; ``` 配置 Flashback Archive: ```sql ALTER FLASHBACK ARCHIVE flar1 SET RETENTION 2 YEARS; ``` 查询 Flashback Archive 信息: ```sql ...
SQL> flashback tablespace users to before drop; ``` #### 五、Oracle Flashback Version Query **Oracle Flashback Version Query** 提供了一种查询表在特定时间点的历史版本的方法。这使得开发人员和DBA能够...