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.

Share and contribute or get technical support and help at My Digital Life Forums.



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

  1. 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.) [...]

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

    These are only to drop the TS

    but not to recover…

    hence the worst….

  3. 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.

  4. 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.

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

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

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 without commenting


Custom Search

New Articles

Incoming Search Terms for the Article

drop tablespace - oracle drop tablespace - recover tablespace - drop tablespace in oracle - drop tablespace oracle - oracle drop database - restore oracle database - alter database drop tablespace - oracle recover database - drop tablespace offline - offline drop - oracle drop table space - offline drop tablespace - datafile offline drop - oracle recover - restore datafile - drop oracle tablespace - remove tablespaces from oracle after disk failure - deleting a table space in oracle 10g - how to drop tablespace in oracle - recover Oracle database - restore datafile oracle - tablespace file missing - missing datafile delete tablespace - drop offline tablespace - oracle create and drop tablespace - drop tablespace offline database oracle - recover data file oracle - > alter database recover database - delete datafile offline oracle - drop oracle database - open oracle db with missing datafiles - oracle delete tablespace file - delete tablespace - drop tablespace - oracle tablespace restore - oracle remove database - dropping tablespace - missing data files + oracle startup - if datafile is offline can we drop tablespace - offline drop; - restore oracle db - drop data file - how to recover corrupted datafile in oracle 9i - offline for drop - oracle+RESTORE DATABASE; - recover dropped tablespace - all - drop tablespaces in oracle - drop tablespace; -