问题描述:当采用以下步骤删除数据文件后发现v$datafile视图中仍然有该文件记录,且状态recover,意识到该删除步骤有问题,生产环境中存在此种情况,此时作为dba应该怎么办?
a、 使用alter database datafile 5 offline;
b、rm 命令删掉数据文件
实验目标:模拟该异常,并提供解决方案.
实验环境:oracle 11.2.0.4+ 单实例
1、模拟异常
SQL>alter tablespace users add datafile '/u01/app/oracle/oradata/leodb/users02.dbf'size 10m autoextend on;
Tablespacealtered.
SQL>select file#,name from v$datafile
FILE# NAME
------------------------------------------------------------
1/u01/app/oracle/oradata/leodb/system01.dbf
2/u01/app/oracle/oradata/leodb/sysaux01.dbf
3/u01/app/oracle/oradata/leodb/undotbs01.dbf
4/u01/app/oracle/oradata/leodb/users01.dbf
5/u01/app/oracle/oradata/leodb/users02.dbf
SQL>select d.tablespace_name,v.file#,d.file_name,d.bytes/1024/1024,v.status,v.enabled,d.autoextensible,d.increment_byfrom dba_data_files d,v$datafile v where d.file_id=v.file#
TABLESPACE_NAME FILE# FILE_NAME D.BYTES/1024/1024 STATUS ENABLED AUT INCREMENT_BY
------------------------- -------------------------------------------------- ------------------------ ---------- --- ------------
USERS 4/u01/app/oracle/oradata/leodb/users01.dbf 5 ONLINE READ WRITE YES 160
UNDOTBS1 3/u01/app/oracle/oradata/leodb/undotbs01.dbf 70 ONLINE R