Drop datafile without dropping a tablespace in Oracle 11g

alter-databasedatafileoracle-11g-r2rmantablespaces

I was trying to take backup of database in Oracle 11g by using RMAN

      $ rman target /
    Recovery Manager: Release 11.2.0.1.0 - Production on Fri Sep 11 10:14:37 2015

    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

    connected to target database: ORCL (DBID=1415405400)

RMAN> backup incremental level 0 as compressed backupset database;

Starting backup at 11-SEP-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
RMAN-06169: could not read file header for datafile 5 error reason 4
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 09/11/2015 10:16:58
RMAN-06056: could not access datafile 5

I have misplaced the datafile then I have added that datafile executing a touch command but still I was getting an error that the database is unable to lock the file. I put the database in mount mode then I took that file offline and after I started backup there was the same error. So how can I solve this error without getting tablespace deleted

Best Answer

The Database Backup and Recovery Reference says that you can do a backup by

backup incremental level 0 as compressed backupset database skip inaccessible;

or better

backup incremental level 0 as compressed backupset database skip offline;

But your problem is that the data from datafile 5 is lot if do do not have a valid backup.

If you have a valid backup vou can restore datafile 5.

If you don't have a valid backup you have two option:

  1. you drop the tablespace and everything from this tablespace will be removed forever

  2. export as much as possible , drop and recreate the tablespace and import what you have exported before.

"export as much as possible" means:

  1. you can export the definitions of the objects from this tablespace because these definitions reside in the SYSTEM tablespace.
  2. if the tablespace consists of more than one datafile you can export the data from all remaining datafiles of this taplespace.

These export can be done with the expdp datapump tool. Use the TABLESPACES parameter to specify the name of the tablespace you want to export. If you only want to export the definitions of the objects set CONTENT=METADATA_ONLY

The import can be done with the impdp tool.