Drop Tablespace Including Contents And Datafiles The Datafiles Are Not Automatically Deleted
(Doc ID 389467.1)
Last updated on AUGUST 04, 2018
Applies to:Oracle Database - Enterprise Edition - Version 10.2.0.1 to 188.8.131.52 [Release 10.2 to 11.1]
Oracle Database - Standard Edition - Version 184.108.40.206 to 10.2.0.2 [Release 9.2 to 10.2]
Microsoft Windows (32-bit)
z*OBSOLETE: Microsoft Windows
z*OBSOLETE: Microsoft Windows Server 2003 R2 (32-bit)
Microsoft Windows x64 (64-bit)
When trying to drop a tablespace including contents and datafiles the datafiles are not
removed from the operating system
Errors may appear like the following:
DROP tablespace NME_TS1 including contents and datafiles
WARNING: Cannot delete file H:\ORADATA\somefile.DBF
Thu Dec 03 07:36:21 2009
Errors in file f:\oracle\admin\gmss\bdump\gmss_j000_3540.trc:
ORA-01265: Unable to delete LOG H:\ORADATA\somefile.DBF
ORA-27056: could not delete file
OSD-04024: Unable to delete file.
O/S-Error: (OS 32) The process cannot access the file because it is being used by another process.
You can drop a tablespace regardless of whether it is online or offline. Oracle recommends that you take the tablespace offline before dropping it to ensure that no SQL statements in currently running transactions access any of the objects in the tablespace.
You cannot drop the SYSTEM tablespace. You can drop the SYSAUX tablespace only if you have the SYSDBA system privilege and you have started the database in MIGRATE mode.
You may want to alert any users who have been assigned the tablespace as either a default or temporary tablespace. After the tablespace has been dropped, these users cannot allocate space for objects or sort areas in the tablespace. You can reassign users new default and temporary tablespaces with the ALTER USER statement.
Any objects that were previously dropped from the tablespace and moved to the recycle bin are purged from the recycle bin. Oracle Database removes from the data dictionary all metadata about the tablespace and all datafiles and tempfiles in the tablespace. The database also automatically drops from the operating system any Oracle-managed datafiles and tempfiles in the tablespace. Other datafiles and tempfiles are not removed from the operating system unless you specify INCLUDING CONTENTS AND DATAFILES.
You cannot use this statement to drop a tablespace group. However, if tablespace is the only tablespace in a tablespace group, then Oracle Database removes the tablespace group from the data dictionary as well.
Restrictions on Dropping Tablespaces
Dropping tablespaces is subject to the following restrictions:
You cannot drop a tablespace that contains a domain index or any objects created by a domain index.
You cannot drop an undo tablespace if it is being used by any instance or if it contains any undo data needed to roll back uncommitted transactions.
You cannot drop a tablespace that has been designated as the default tablespace for the database. You must first reassign another tablespace as the default tablespace and then drop the old default tablespace.
You cannot drop a temporary tablespace if it is part of the database default temporary tablespace group. You must first remove the tablespace from the database default temporary tablespace group and then drop it.
You cannot drop a tablespace, even with the INCLUDING CONTENTS and CASCADE CONSTRAINTS clauses, if doing so would disable a primary key or unique constraint in another tablespace. For example, if the tablespace being dropped contains a primary key index, but the primary key column itself is in a different tablespace, then you cannot drop the tablespace until you have manually disabled the primary key constraint in the other tablespace.
Oracle Database Data Cartridge Developer's Guide and Oracle Database Concepts for more information on domain indexes
Specify INCLUDING CONTENTS to drop all the contents of the tablespace. You must specify this clause to drop a tablespace that contains any database objects. If you omit this clause, and the tablespace is not empty, then the database returns an error and does not drop the tablespace.
DROP TABLESPACE fails, even if you specify INCLUDING CONTENTS, if the tablespace contains some, but not all, of the partitions or subpartitions of a single table. If all the partitions or subpartitions of a partitioned table reside in tablespace, then DROP TABLESPACE ... INCLUDING CONTENTS drops tablespace, as well as any associated index segments, LOB data segments, and LOB index segments of table in other tablespace(s).
For a partitioned index-organized table, if all the primary key index segments are in this tablespace, then this clause will also drop any overflow segments that exist in other tablespaces, as well as any associated mapping table in other tablespaces. If some of the primary key index segments are not in this tablespace, then the statement will fail. In that case, before you can drop the tablespace, you must use ALTER TABLE ... MOVE PARTITION to move those primary key index segments into this tablespace, drop the partitions whose overflow data segments are not in this tablespace, and drop the partitioned index-organized table.
If the tablespace contains a master table of a materialized view, then the database invalidates the materialized view.
If the tablespace contains a materialized view log, then the database drops the log and any other direct-path INSERT refresh information associated with the table.
When you specify INCLUDING CONTENTS, the AND DATAFILES clause lets you instruct the database to delete the associated operating system files as well. Oracle Database writes a message to the alert log for each operating system file deleted. This clause is not needed for Oracle-managed files, because they are removed from the system even if you do not specify AND DATAFILES.
OracleÂ® Database SQL Language Reference
11g Release 1 (11.1)
Part Number B28286-05
To view full details, sign in with your My Oracle Support account.
Don't have a My Oracle Support account? Click to get started!
In this Document