If you delete a data file in a tablespace before Oracle10g, the file will still exist in the Database Data Dictionary. Unless you delete the tablespace, the file information will not be cleared.
However, from Oracle10gR2, Oracle allows us to completely delete an empty file without any trace.
But note: if you wantSYSTEMIf a file is added incorrectly in the tablespace, it is better to leave it unchanged.
For common tablespaces, follow these steps.
Database Version Oracle10gR2:
SQL> select * from v $ version; BANNER ---------------------------------------------------------------- OracleDatabase10g Enterprise Edition Release 10.2.0.1.0-Prod PL/SQL Release 10.2.0.1.0-Production CORE 10.2.0.1.0 Production TNS for Linux: Version 10.2.0.1.0-Production NLSRTL Version 10.2.0.1.0-Production |
Add a data file to the USERS tablespace:
SQL> alterTablespaceUsers add datafile '/opt/oracle/oradata/eygle/users02.dbf' size 10 M; Tablespace altered. SQL> selectFile#, Name from v $ 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 5 rows selected. |
Confirm the tablespace file information:
SQL> select file_name, file_id from dba_data_files where tablespace_name = 'users '; FILE_NAME FILE_ID ------------------------------------------------------------ /Opt/oracle/oradata/eygle/users02.dbf 5 /Opt/oracle/oradata/eygle/users01.dbf 4 |
Confirm that the tablespace is not occupied by storage:
SQL> select segment_name, file_id, blocks from dba_extents where file_id = 5; No rows selected |
Delete An Empty data file in a tablespace:
SQL> alterTablespaceUsers drop datafile '/opt/oracle/oradata/eygle/users02.dbf '; Tablespace altered. |
Check the data dictionary. The information of this empty file has been completely cleared:
SQL> select file_name, file_id from dba_data_files where tablespace_name = 'users '; FILE_NAME FILE_ID ------------------------------------------------------------ /Opt/oracle/oradata/eygle/users01.dbf 4 |