DBA Tips Archive for Oracle

  


Dropping Tablespaces and Datafiles in Oracle9i

by Jeff Hunter, Sr. Database Administrator


Contents

  1. Introduction / Solution
  2. Example



Introduction / Solution

With release 9i (and future releases), Oracle is making significant strides in making the database easier to manage. One annoying issue with Oracle databases prior to 9i, is when you dropped a tablespace, you would also have to remember to remove the physical datafile associated with that tablespace.

With the introduction of Oracle9i, there are two ways to allow Oracle to handle the removal of the datafiles when dropping the tablespace. The first is to use a new feature called Oracle-Managed Files (OMFs). This feature allows the Oracle RDBMS to manage datafiles for you. Click here for an indepth discussion on Oracle-Managed Files.

The second method can be used for DBAs who do not want to use OMFs. Simply use the INCLUDING CONTENTS AND DATAFILES clause to the end of your DROP TABLESPACE statement. See the example below for how this new feature works.



Example

  SQL> CREATE TABLESPACE users_temp
    2  DATAFILE '/u10/app/oradata/CUSTDB/users_temp01.dbf' SIZE 1M REUSE;

  Tablespace created.


  SQL> !ls -l /u10/app/oradata/CUSTDB/users_temp01.dbf
  -rw-r-----   1 oracle  dba    1056768 Apr  2 18:19 /u10/app/oradata/CUSTDB/users_temp01.dbf


  SQL> DROP TABLESPACE users_temp INCLUDING CONTENTS AND DATAFILES;

  Tablespace dropped.


  SQL> !ls -l /u10/app/oradata/CUSTDB/users_temp01.dbf
  ls: /u10/app/oradata/CUSTDB/users_temp01.dbf: No such file or directory


Copyright (c) 1998-2017 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Friday, 20-Jan-2006 15:45:31 EST
Page Count: 7819