Unfortunately, you can't. Prior to Oracle Database 10g Release 2, your only clean option for
removing a datafile is to drop the entire tablespace and then rebuild it without that
particular file. If the tablespace contains data, you have to go through the time-consuming
and laborious process of storing the data on a separate location and reinstating it. In
addition to its inconvenience, this process makes the tablespace unavailable.
Thankfully, in Oracle Database 10g Release 2 the process has been simplified: You can just
drop the datafile. For example, the following command will remove the indicated datafile from
the tablespace as well as from the server.
SQL> alter tablespace users drop datafile '/u01/users02.dbf';
There are a couple restrictions, however: The datafile must be empty to be dropped. You can't
drop the last datafile in a tablespace; the tablespace itself must be dropped. And the
tablespace must be online and in read-write status.
|