如果是在Oracle10g之前,删除一个表空间中的数据文件后,其文件在数据库数据字典中会仍然存在,除非你删除表空间,否则文件信息不会清除。
但是从Oracle10gR2开始,Oracle允许我们彻底删除一个空文件,不留痕迹。
但是注意:如果你向SYSTEM表空间错误的添加了一个文件,那么就让它在哪里好了,不要动。
对于普通表空间,则可以参考以下步骤处理。
数据库版本Oracle10gR2:
SQL>select*fromv$version; BANNER ---------------------------------------------------------------- OracleDatabase10gEnterpriseEditionRelease10.2.0.1.0-Prod PL/SQLRelease10.2.0.1.0-Production CORE10.2.0.1.0Production TNSforLinux:Version10.2.0.1.0-Production NLSRTLVersion10.2.0.1.0-Production |
向USERS表空间增加一个数据文件:
SQL>altertablespaceusersadddatafile'/opt/oracle/oradata/eygle/users02.dbf'size10M; Tablespacealtered. SQL>selectfile#,namefromv$datafile; FILE#NAME ------------------------------------------------------------ 1/opt/oracle/oradata/eygle/system01.dbf 2/opt/oracle/oradata/eygle/undotbs01.dbf 3/opt/oracle/oradata/eygle/sysaux01.dbf 4/opt/oracle/oradata/eygle/users01.dbf 5/opt/oracle/oradata/eygle/users02.dbf 5rowsselected. |
确认表空间文件信息:
SQL>selectfile_name,file_idfromdba_data_fileswheretablespace_name='USERS'; FILE_NAMEFILE_ID ------------------------------------------------------------ /opt/oracle/oradata/eygle/users02.dbf5 /opt/oracle/oradata/eygle/users01.dbf4 |
确认表空间未被存储占用:
SQL>selectsegment_name,file_id,blocksfromdba_extentswherefile_id=5; norowsselected |
删除表空间中的空数据文件:
SQL>altertablespaceusersdropdatafile'/opt/oracle/oradata/eygle/users02.dbf'; Tablespacealtered. |
检查数据字典,这个空文件的信息已经被彻底清除了:
SQL>selectfile_name,file_idfromdba_data_fileswheretablespace_name='USERS'; FILE_NAMEFILE_ID ------------------------------------------------------------ /opt/oracle/oradata/eygle/users01.dbf4 |