SQL>startup mount;
SQL>startup force mount;
|
SQL>! cp ‘backup.dbf’ ‘/xxx/aaa’
|
SQL>recover datafile file#
SQL>recover from ‘/u01/oracle/xxx.log’ datafile file#
SQL>
recover database
databasename
|
SQL> alter database open;
Database altered.
|
SQL>startup mount;
SQL>startup force mount;
SQL>select file#,error from v$recover_file;
SQL>alter database datafile file# offline;
SQL>alter database open
|
SQL>select file#,error from v$recover_file ;
SQL>alter database datafile file# offline;
|
SQL>! cp ‘backup.dbf’ ‘/xxx/aaa’
|
SQL>recover datafile file#
SQL>recover from ‘/u01/oracle/xxx.log’ datafile file#
SQL>recover tablespace tablespacename;
|
SQL>alter database datafile file# online;
|
SQL> alter system switch logfile;
SQL> create table t(i number) tablespace system;
SQL> insert into t values(1);
SQL> insert into t values(2);
SQL> insert into t values(3);
SQL> commit;
SQL> alter system switch logfile;
SQL> select * from t;
I
-------------------
1
2
3
|
SQL> shutdown immediate;
SQL> ! mv /u01/oradata/denver/system01.dbf /u01/oradata/denver/system01.dbf.bak
|
SQL> startup;
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/oradata/denver/system01.dbf'
SQL> select status from v$instance;
STATUS
------------
MOUNTED
#
只能启动到
mounted
状态
|
SQL> col error format a30
SQL> select file#,error,change# from v$recover_file;
FILE# ERROR CHANGE#
---------- ------------------------------ -------------------------------------
1 FILE NOT FOUND 0
|
SQL> col archive_name format a30
SQL> select sequence#,archive_name from v$recovery_log;
SEQUENCE# ARCHIVE_NAME
------------------- ----------------------------------------------
29 /u01/oradata/denver/archive/1_29.dbf
#
只要归档日志
1_29.dbf
还存在就能恢复
|
SQL> ! cp /u01/backup/system01.dbf /u01/oradata/denver/
SQL> select file#,error,change# from v$recover_file;
FILE# ERROR CHANGE#
---------- ------------------------------ ------------------------------------------
1 1661187
|
#1_29.dbf
不在默
认归
档目
录
下
SQL> recover from '/u01/oradata/denver/archive/1_29.dbf datafile 1;
#1_29.dbf
在默
认归
档目
录
下
SQL> recover datafile 1;
ORA-00279: change 1661187 generated at 05/05/2009 21:51:54 needed for thread 1
ORA-00289: suggestion : /u01/oradata/denver/archive/1_29.dbf
ORA-00280: change 1661187 for thread 1 is in sequence #29
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
Log applied.
Media recovery complete.
|
SQL> alter database open;
Database altered.
SQL> select * from t;
I
--------------------
1
2
3
#
可见恢复成功了
|
SQL> create tablespace chenxy datafile '/u01/oradata/denver/chenxy.dbf' size 2M;
SQL> create table chenxy(i number) tablespace chenxy;
SQL> insert into chenxy values(10);
SQL> insert into chenxy values(20);
SQL> commit;
SQL> alter system switch logfile;
SQL> select * from chenxy;
I
-------------------
10
20
|
SQL> ! mv /u01/oradata/denver/chenxy.dbf /u01/oradata/denver/chenxy.dbf.bak;
|
SQL> select * from chenxy;
ERROR at line 1:
ORA-00376: file 13 cannot be read at this time
ORA-01110: data file 13: '/u01/oradata/denver/chenxy.dbf'
|
SQL> select file#,error,change# from v$recover_file;
FILE# ERROR CHANGE#
-------------- ------------------------------------------------------------- ----------
13 FILE NOT FOUND 0
SQL> select status from v$datafile where file#=13;
STATUS
-------
RECOVER
|
SQL> alter database datafile 13 offline;
#
如果有备份的数据文件
SQL>! cp backup.dbf
'/u01/oradata/denver/chenxy.dbf';
#l
因为没有备份
,
现在用控制文件新建数据文件
SQL> alter database create datafile '/u01/oradata/denver/chenxy.dbf';
SQL> select file#,error,change# from v$recover_file;
FILE# ERROR CHANGE#
---------- ------------------------------ ----------------------------------------
13 1662171
|
SQL> recover datafile 13;
Media recovery complete.
SQL> alter database datafile 13 online;
|
SQL> select * from chenxy;
I
--------------------
10
20
|
recover database
用来恢
复
整个数据
库
的所有数据文件
,
只能在
mount
状
态
运行
recover tablespace
用来恢
复
某个表空
间
的所有数据文件
,
只能在
open
状
态
运行
recover datafile
用来恢
复
某个数据文件
,
在
mount,open
状
态
都可以运行
|
v$recover_file
显
示需要恢
复
的数据文件
v$recovery_log
显
示恢
复
所需的
归
档日志
,
如果恢
复
所需的日志
丢
了
,
也就
别
想恢
复
了
,
v$archived_log
显
示所有的
归
档日志
v$loghist
显
示
归
档日志
SCN
信息
|