How Drop Tablespace and Recover Oracle Database When Accidentally Delete Datafile

Accident may happens, even though it’s costly one. This is especially the case in Oracle database, which stores the database objects physically in data files on hard disk. Fast hand administrators may accidentally delete some of the datafiles, or the datafiles may get corrupted or unreadable on hard disk failure. You may get also some missing datafiles after database recovery process. In any case, missing a or a few datafiles will cause Oracle database to fail to startup, rendering the whole DB inaccessible.

The solution to the missing datafiles is to drop the affected tablespace where has incomplete datafiles, and then recreate the tablespace and import the data into the tablespace from backup. However, the steps are not so straight forward.

  1. Run SQL*Plus.
  2. Connect to database as SYSDBA with this query:

    CONNECT / AS SYSDBA

  3. Mount the database instead of starting it up:

    STARTUP MOUNT;

  4. Issue the following command to bring the missing datafile offline so that Oracle won’t trying to connect and access the datafile anymore:

    ALTER DATABASE DATAFILE ‘<datafile name with complete path>’ OFFLINE DROP;

    Repeat the command for every datafiles that unaccounted for.

  5. Now start the database proper:

    ALTER DATABASE OPEN;

  6. As the tablespace has damaged, drop it to recreate from fresh backup.

    DROP TABLESPACE <tablespace name> INCLUDING CONTENTS;

  7. Ensure the other datafiles for the tablespace has been deleted, if not, remove them manually from the operating system.

    Tip: How to check datafiles that belong to tablespace.

  8. Continue with the recovery process.

12 Responses to “How Drop Tablespace and Recover Oracle Database When Accidentally Delete Datafile”

  1. Makina
    October 16th, 2009 04:14
    12

    “How Drop Tablespace and Recover Oracle Database When Accidentally Delete tablespace?”

  2. Dan
    May 21st, 2009 10:08
    11

    Exactly what I needed! Thanks for saving what seemed to be a wretched issue!

  3. lara
    April 20th, 2009 20:47
    10

    thanks a million.
    u r a life saver

  4. Dewan Gazzali
    February 19th, 2009 06:49
    9

    This is a life saver …. this works fine in oracle 10G HP itenium (or any where else).
    great doc.
    thanks
    Dewan Gazzali

  5. Nora
    December 17th, 2008 13:53
    8

    *2nds last post*

  6. Michael
    November 6th, 2008 06:15
    7

    You are a life saver!!!!!!

  7. mark
    October 28th, 2008 03:09
    6

    I ran a script to create a user w/o checking it closely enough. Next thing you know, my db won’t start because it is looking for a data file that doesn’t exist. This tip helped me get around the error quickly. Thanks for posting it.

  8. Steve
    October 9th, 2008 02:31
    5

    Thank you for taking the time to post this very valuable information. :)

  9. Cesar
    September 2nd, 2008 00:31
    4

    Thank you very much, this was really helpful.
    I had problems dropping the tablespace, i had to drop the user also.

  10. ravisha
    July 8th, 2008 19:31
    3

    This info helped us to a very great extent and hence we are able to proceed further smoothly.

  11. LP
    April 2nd, 2008 18:27
    2

    These are only to drop the TS

    but not to recover…

    hence the worst….

  12. How to Remove and Drop Datafiles from Tablespace in Oracle Database » My Digital Life
    August 4th, 2007 02:57
    1

    [...] If one or more datafiles is missing after a recovery process or accidental deletion, you can use ALTER DATABASE DATAFILE <datafile name> OFFLINE DROP command to make the datafile offline so that database can starts up after which the troubled tablespace can be dropped. (See instruction to recover from missing datafiles.) [...]

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.

New Articles

Incoming Search Terms for the Article

drop tablespace oracle - alter tablespace offline drop - oracle alter database add tablespace - drop tablespace force - dropping tablespace in oracle - oracle tablespace offline - tablespace recovery oracle - oracle drop tablespace before full database import - tablespace offline drop - datafile offline drop - how to drop tablespace in oracle - accidentally deleted oracle dbs - OFFLINE FOR DROP - oracle 10g recover datafile - DROP TABLESPACE OFFLINE - how to recover deleted oracle database - alter tablespace offline mount - oracle recover deleted datafile - oracle import datafile - oracle delete table space - oracle drop tablespace force - drop tablespace mounted database - drop tablespaces in oracle - oracle drop tablespace datafiles corrupt - oracle missing datafile drop tablespace - tablespace drop offline - drop oracle tablespaces - remove tablespace when database is not open - dropped tablespace recovery - oracle alter database drop tablespace - to recover drop user in oracle 10g - drop tablespace missing datafiles - oracle mount drop tablespace - oracle delete tablespace - drop+oracle+tablespace+while+offline - how to recover database in oracle - offline drop tablespace - oracle drop tablespace - alter table remove tablespace - drop tablespace database not open - missing data file how to offline drop oracle - oracle error dropping tablespace - tablespace offline drop in oracle - drop table in oracle mount stage - oracle missing datafiles recover database - oracle recovery one tablespace - recovery of tablespaces in oracle - alter database tablespace offline - dropping a tablespace in oracle - how to recover missing data in focus -