首先问一下,你周二新增datafile以后有没有做过备份?有的话,情况就是数据库有备份,但datafile必须换位置(因为硬盘损坏)
RMAN SCRIPT:run{
set newname for datafile BackupPieceNo to 'NewFile';   
restore datafile BackupPieceNo;
switch datafile 'OldFile' to datafilecopy 'NewFile'; 
recover datafile BackupPieceNo;
}  如果你在新增datafile后,没有做过备份,但日志文件保全:
(这个情况我没试过~ 因为每次数据库文件结果发生变动,理论上都需要做备份)
1. startup mount
2. alter database backup controlfile to trace;  (获取当前controlfile的内容,去udump下最新的文件找)
3. shutdown immediate;
4. 把找到的controlfile script打开,修改其中的datafile存储路径(test02.dbf的路径)
5. 创建新的controlfile,然后startup mount;
6. recover database until cancel;  
7. alter database open;

解决方案 »

  1.   

    是的,从我增加datafile 那一刻起,所有的归档都是完好的,且redo也一切完好,但没有再做过备份了,那么,你说的重点就是在recover database  上,
    是不是执行此命令后,先使用 archive log,,再使用 Redo log来恢复?
      

  2.   

    没做过备份,那就是第二种情况.
    先修改controlfile,把test02.dbf的路径换掉(硬盘坏了,总不能不换个地方存吧)然后再recover database until cancel;  
    这句的意思大致是根据最新的SCN, oracle自动恢复到最新的状态.
    (因为我没做过这个情况的实验,所以没法做100%的确定)
      

  3.   

    是使用归档log还是online log,  oracle自行判断的.(是依靠SCN编码来判断的)所以所有的日志都不要去动它, 先把test02.dbf的存储路径换掉,
    然后执行recover database until cancel;
      

  4.   

    有人建议:
    startup mount;
    alter datafile <corrupt_filename> offline;
    alter database create datafile '<corrupt_filename>' as '<new_filename>' ... 是不是 9I 直接支持 alter database create datafile '<corrupt_filename>' as '<new_filename>' 
    不需要从control文件去修改那么麻烦? 
      

  5.   

    你说的貌似可行~ 你参考一下oracle给出的例子:
    (但oracle的例子是更名一个完好的datafile, 你的datafile已经损坏掉了,能不能更改是个问题,有待考证)
    To rename datafiles from a single tablespace, complete the following steps:
    1. Take the non-SYSTEM tablespace that contains the datafiles offline.
    For example:
    ALTER TABLESPACE users OFFLINE NORMAL;
    2. Rename the datafiles using the operating system.
    3. Use the ALTER TABLESPACE statement with the RENAME DATAFILE clause to
    change the filenames within the database.
    For example, the following statement renames the datafiles
    /u02/oracle/rbdb1/user1.dbf and /u02/oracle/rbdb1/user2.dbf
    to/u02/oracle/rbdb1/users01.dbf and /u02/oracle/rbdb1/users02.dbf,
    respectively:
    ALTER TABLESPACE users
    RENAME DATAFILE '/u02/oracle/rbdb1/user1.dbf',
    '/u02/oracle/rbdb1/user2.dbf'
    TO '/u02/oracle/rbdb1/users01.dbf',
    '/u02/oracle/rbdb1/users02.dbf';
    The new files must already exist; this statement does not create the files. Also,
    always provide complete filenames (including their paths) to properly identify
    the old and new datafiles. In particular, specify the old datafile name exactly as
    it appears in the DBA_DATA_FILES view of the data dictionary.
    4. Back up the database. After making any structural changes to a database,
    always perform an immediate and complete backup.
      

  6.   

    在恢复的时候,我是要恢复 datafile  还是 database??
    recover datafile <new_filename>;
    alter datafile <new_filename> online; recover database until cancel;
    到底做哪一种恢复?
      

  7.   

    我试了下你说的~ 不行~
    因为在mount情况下, 根本做不了单个tablespace或单个datafile offline 
    (他们本来就没online,属于未知状态,不能更改)其实从新做个controlfile很快的~ 因为oracle会帮你生成controlfile的create script,
    你去修改一下test02.dbf的路径就可以了.
      

  8.   

    SQL>startup mount
    SQL>select name,file# from v$datafile;
    找到损坏的数据库的编号,假如查出编号file#为7
    SQL>alter database create datafile 7 as ‘/opt/oracle/oradata/test02.dbf’ size 100m;
    SQL>recover database using backup controlfile;
    按提示给出归档日志,最新归档日志给完之后,还要给联机日志。
    恢复成功后即可开启数据库
    SQL>alter database open resetlogs;
    恢复成功,多谢各位相助!