数据文件如果不重要
则
SQL>startup mount
--ARCHIVELOG模式命令
SQL>Alter database datafile 'file name' offline;
--NOARCHIVELOG模式命令
SQL>Alter database datafile 'file name' offline drop;
SQLl>Alter database open;
则
SQL>startup mount
--ARCHIVELOG模式命令
SQL>Alter database datafile 'file name' offline;
--NOARCHIVELOG模式命令
SQL>Alter database datafile 'file name' offline drop;
SQLl>Alter database open;
4.2.1 OS备份方案
在归档方式下损坏或丢失一个数据文件,如果存在相应的备份与该备份以来的归档日志,恢复还是比较简单的,可以作到尽量少的Down机时间,并能作到数据库的完全恢复。
1、连接数据库,创建测试表并插入记录
SQL*Plus: Release 8.1.6.0.0 - Production on Tue May 6 13:46:32 2003
(c) Copyright 1999 Oracle Corporation. All rights reserved.
SQL> connect internal/password as sysdba;
Connected.
SQL> create table test(a int) tablespace users;
Table created
SQL> insert into test values(1);
1 row inserted
SQL> commit;
Commit complete2、备份数据库
SQL> @hotbak.sql 或在DOS下 svrmgrl @hotbak.sql3、继续在测试表中插入记录
SQL> insert into test values(2);
1 row inserted
SQL> commit;
Commit complete
SQL> select * from test;
A
---------------------------------------
1
2
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.4、关闭数据库,模拟丢失数据文件
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down
C:\>del D:\ORACLE\ORADATA\TEST\USERS01.DBF
模拟媒体毁坏5、启动数据库错误,脱机该数据文件
SQL> startup
ORACLE instance started.Total System Global Area 102020364 bytes
Fixed Size 70924 bytes
Variable Size 85487616 bytes
Database Buffers 16384000 bytes
Redo Buffers 77824 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: 'D:\ORACLE\ORADATA\TEST\USERS01.DBF'
还可以查看报警文件(见上一个恢复案例)或动态视图v$recover_file
如SQL> select * from v$recover_file; FILE# ONLINE ERROR CHANGE# TIME
---------- ------- ------------------ ---------- -----------
3 ONLINE 1013500 2003-05-07脱机数据文件
SQL> alter database datafile 3 offline drop;
Database altered.6、打开数据库,拷贝备份回来(restore),恢复(recover)该数据文件,并联机
SQL> alter database open;
Database altered.
拷贝备份从备份处
copy d:\databak\ users01.dbf d:\oracle\oradata\test;
恢复该数据文件
我用sqlplus /nolog;
conn system/password as sysdba;
仍然不行,因为数据库仍然未装上。
SQL>conn sys/password as sysdba;
只有sys(它的系统权限是sysdba)行,
而不是system(它的系统权限是dba)。
再按:
penitent(只取一瓢)的操作