关于 数据文件 恢复的四种 情况 (必要的时候 可以练练)

本文详细介绍了在不同场景下进行数据库恢复的具体步骤,包括数据库未打开状态、当前打开状态、初始关闭状态以及丢失文件无备份情况下的恢复流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Below workshop, I will perform some workshops about the database recovery:

Step1:
   when the database in not open status:
 
  1: when the database open, remove all the datafile.
  2: shutdown the database abort. (shutdown immdiate will cause error).
  3: startup mount
  4: copy the cold backup datafile into the defination direction.
  5: Because the current control file is latest, but the datafile is old,
    if open the database, database will not open.
  6: using v$recover_file the check which datafile should br recovery.
  7: set autorecovery off
    (if you "set autorecovery on", the archived logs will be recovered automatic )
    so suggestion is : set autorecovery on
  8: recover database (you can use recover datafile 1,2).
  9:select * from v$recover_file
    (you will see no records)
  10: alter database open;
 

Step2:
  When the database is current open:
 
  Use this method when:
    1: The database is current open
    2: The database will remain open during the recovery.
    3: The media failure dose not affect the SYSTEM tablespace.
   
  Below is the recovery steps:
 
  1: I will simulate the tablespace file missing.
  2: insert into table ( write the data into memory)--- commit (writer the data into redo file).
  3: alter system checkpoint
    (This action is to write the data from memory to tablespace file).
  4: select * from v$recover_file;
    (You will see one record about the tablespace line)
  5: alter database datafile 6 offline
    (you can also use below command:)
    alter tablespace tablespace_name offline;
  6: copy the bakcup datafile : tbs01.dbf into the defination direction.
  7: recover datafile 6;
    (because this time the control file , redo file do not corresponding to datafile 6 )
  8: select file#,status,name from v$datafile
    (you will find the datafile 6 is offline)
  9: select * from v$recover_file
    (you will not see any records in the view)
  10:select * from v$datafile;
    You wil see datafile 6 is offline.
     alter database datafile 6 online.
  11: alter database open;
  12 :Check the data is available.
 
 
Step3:
  Recovery when the DB is init closed:
 
  Use this method when:
  1: The database is currently closed.
  2: The database will be opened during recovery.
  3: The media failure dose not affect the SYSTEM tablespace.
 
  The recovery steps:
 
  1: Mount the database
  2: Take datafile 2 offline.
  3: Open the database.
  4: Restore datafile 2.
  5: recovery datafile 2.
  6: Take datafile 2 online.
 
Step4:

  Recovery File without a backup:
 
  Condition:
  1: Datafile is lost that was never backed up.
  2: Can not used when it is a file from SYSTEM tablespace.
  3: Can not used if control file has been related.
 
  Notice:
 
  If datafile is damaged and no backup of the file is available, then you still
  can recovery the datafile if:
 
  1: All archived log files written after the creation of the original datafile are available
  2: The control file contains the name of the damaged file (that is, the control file is current,
    or it oss a backup taken after the damaged datafil was added to the database).
   
Notice:
  You can not re-create any of the datafiles for SYSTEM tablespace by using any
  COMMAND: create datafile... ,because the necessary redo is not available.
 
 
  Re-create Lost Datafiles:
 
  1: Used when missing datafile cannot be restored
    because it had never been backed up.
   
  2: Description of missing datafile is still in data dictionary and control file.
 
  3: Re-create the datafile:
 
    SQL>Alter database create datafile 'filename';
   
    Re-create the datafile with a different filename:
   
    SQL> Alter database create datafile 'filename' as 'new file name';
   
   
Restore this case steps:
  1: take the datafile offline.
  2: create new datafile
  3: recovery datafile.
  4: take the datafile online.
  5: Open the database.
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shenghuiping2001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值