开发同事误删除了一个dbf文件,导致数据库启动出错。
其实出现这个问题,首先在管理上就有问题,不应该给开发这么大的权限。
补救方法很多,随便挑选一个:
alter database datafile '/u01/app/oracle/oradata/pdf1.dbf' offline ;
*
ERROR at line 1:
ORA-01145: offline immediate disallowed unless media recovery enabled
数据库未开归档,所以不能这么做,
alter database datafile '/u01/app/oracle/oradata/pdf1.dbf' offline drop;
官方文档里这样说:
DATAFILE Clauses
The DATAFILE clauses affect your database files as follows:
ONLINE
Specify ONLINE to bring the datafile online.
OFFLINE
Specify OFFLINE to take the datafile offline. If the database is open, you must perform media recovery on the datafile before bringing it back online, because a checkpoint is not performed on the datafile before it is taken offline.
DROP
If the database is in NOARCHIVELOG mode, you must specify the DROP clause to take a datafile offline. However, the DROP clause does not remove the datafile from the database. To do that, you must drop the tablespace in which the datafile resides. Until you do so, the datafile remains in the data dictionary with the status RECOVER or OFFLINE.
所以执行了offline drop之后,其实物理的数据文件还是未删除,所以这个时候你也不能手动rm-rf删除,因为别的数据字典还记录这个数据文件,所以你需要在表空间几倍删除他,drop tablespace tbs_name including contexts and datafiles;