How Drop Tablespace and Recover Oracle Database When Accidentally Delete Datafile

»»»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:
  3. Mount the database instead of starting it up:
  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:
  6. As the tablespace has damaged, drop it to recreate from fresh backup.
  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.

By |2016-12-09T08:39:39+00:00December 9th, 2016|Categories: Databases|Tags: , |19 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.