Drop a datafile

Hello, I was adding data files to a tablespace and I added one that I did not want so I did an "alter database datafile... offline drop'. The file is still there. Is there a way to get rid of it, hopefully without bringing down the database. Thank you,
David

Even if this is dirty to have an unused referenced file... and if you haven't any extent into this datafile it should work :
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
SQL> create tablespace test datafile 'E:\oracle\oradata\DEMO92\TEST01.DBF' size 10M;
Tablespace created.
SQL> create table emp tablespace test as select * from scott.emp;
Table created.
SQL> select tablespace_name from user_tables where table_name = 'EMP'
SQL> /
TABLESPACE_NAME
TEST
SQL> alter tablespace test add datafile 'E:\oracle\oradata\DEMO92\TEST02.DBF' size 10M
SQL> /
Tablespace altered.
SQL> select file_name,bytes from dba_data_files where tablespace_name = 'TEST'
SQL> /
FILE_NAME                                  BYTES
E:\ORACLE\ORADATA\DEMO92\TEST01.DBF     10485760
E:\ORACLE\ORADATA\DEMO92\TEST02.DBF     10485760
SQL> alter database datafile 'E:\ORACLE\ORADATA\DEMO92\TEST02.DBF' offline drop;
Database altered.
SQL> select file_name,bytes from dba_data_files where tablespace_name = 'TEST'
  2  /
FILE_NAME                                  BYTES
E:\ORACLE\ORADATA\DEMO92\TEST01.DBF     10485760
E:\ORACLE\ORADATA\DEMO92\TEST02.DBF    
SQL> select count(*) from emp;
  COUNT(*)
        14
SQL> select tablespace_name from user_tables where table_name = 'EMP'
  2  /
TABLESPACE_NAME
TEST
SQL> select file_name,bytes, status from dba_data_files where tablespace_name = 'TEST';
FILE_NAME                                  BYTES STATUS
E:\ORACLE\ORADATA\DEMO92\TEST01.DBF     10485760 AVAILABLE
E:\ORACLE\ORADATA\DEMO92\TEST02.DBF              AVAILABLE
SQL> begin
  2  for i in 1..10 loop
  3   insert into emp select * from emp;
  4  end loop;
  5* end;
SQL> /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> select count(*) from emp;
  COUNT(*)
     14336
SQL> select sum(bytes) from user_extents where segment_name='EMP';
SUM(BYTES)
   9437184
SQL> insert into emp select * from emp;
insert
ERROR at line 1:
ORA-01653: unable to extend table SYSTEM.EMP by 128 in tablespace TEST
ORA-06512: at line 1
SQL> alter tablespace test add datafile 'E:\oracle\oradata\DEMO92\TEST03.DBF' size 10M;
Tablespace altered.
SQL> insert into emp select * from emp;
14336 rows created.
SQL> select count(*) from emp;
  COUNT(*)
     28672
SQL> select sum(bytes) from user_extents where segment_name='EMP';
SUM(BYTES)
  18874368
SQL> select file_name,bytes, status from dba_data_files where tablespace_name = 'TEST';
FILE_NAME                                  BYTES STATUS
E:\ORACLE\ORADATA\DEMO92\TEST01.DBF     10485760 AVAILABLE
E:\ORACLE\ORADATA\DEMO92\TEST02.DBF              AVAILABLE
E:\ORACLE\ORADATA\DEMO92\TEST03.DBF     10485760 AVAILABLE
--here I drop the file from the disk
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area  135339604 bytes
Fixed Size                   454228 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL> select file_name, status from dba_data_files where tablespace_name='TEST'
FILE_NAME                               STATUS
E:\ORACLE\ORADATA\DEMO92\TEST01.DBF     AVAILABLE
E:\ORACLE\ORADATA\DEMO92\TEST02.DBF     AVAILABLE
E:\ORACLE\ORADATA\DEMO92\TEST03.DBF     AVAILABLE
SQL> drop tablespace test including contents and datafiles;
Tablespace dropped.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area  135339604 bytes
Fixed Size                   454228 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL>Nicolas.

Similar Messages

  • How to drop the datafile in a tablespace

    hi,
    I need to drop the datafile in a tablespace.How to drop the datafile in the tablespace.If iam able to drop the datafile and is it possible to create the datafiles with the same name.could u pls help me out..
    Thanks in advance,
    R.Ratheesh

    sql > alter database <datafile> offline drop ;
    sql > alter database open ;What if the datafile have the segments in it, I believe users will not be able to access them. And system will put the datafile to Recovry mode not drop it.
    Dropping a datafle is possible only in 10G. In 9i you can reduce the size of file below the size of your min extents so that the space wont be allocated from that datafile or you may need to recreate a new tablespace copy all the segments from old tablespace and drop old one.
    Cheers

  • Recover from dropped SYSAUX datafile

    Trying to recover a DEV database without rebuilding it, but not hopeful at this point. Basically, someone dropped the SYSAUX (and a few other) datafiles, so now they are showing up in the database as MISSING0003 instead of the actual filename. There are no backups, but I want to drop the tablespaces (not SYSAUX) and in trying to do so, I'm getting an error about the SYSAUX tablespace for some reason. How can I rebuild or recover from the SYSAUX issue, since I cannot drop the SYSAUX tablespace, as it seems to be preventing me from dropping any of the other tablespaces that have missing datafiles as well. I really just need to recreate the tablespaces, but get the below error when I try to drop the schemas (with cascade) or the tablespaces (including contents).
    SQL> drop tablespace DATA001 including contents;
    drop tablespace DATA001 including contents
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 2
    ORA-00376: file 3 cannot be read at this time
    ORA-01111: name for data file 3 is unknown - rename to correct file
    ORA-01110: data file 3: 'C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\MISSING00003'
    ORA-06512: at line 19
    Any help to get past the first issue of dropping the non-SYSTEM tablespaces would be great, and any follow-up on how to rebuild/recreate/recover from the dropped SYSAUX datafiles would be appreciated as well.
    DB is 10gR2 on Windows.

    user4257171 wrote:
    Trying to recover a DEV database without rebuilding it, but not hopeful at this point. Basically, someone dropped the SYSAUX (and a few other) datafiles, so now they are showing up in the database as MISSING0003 instead of the actual filename. There are no backups,
    > DB is 10gR2 on Windows.
    Without backups you are not going to be able recover the dropped data files. Given that one of the tablespaces was the required SYSAUX tablespace you are most likely looking at a rebuild instead of a restore.

  • Drop a datafile that is offline and not on the OS

    I am running a 2 node rac on ASM . 10gR2 on HP UX.
    By mistake 1 datafile has been deleted on the OS , and that datafile is marked as offline in the dba_data_files.
    How can I drop the datafile from the database.
    since when I query the dba_data_files the datafile 10 ( which was deleted on OS ) , shows its still present and online_status is offline.
    The datafile is not required and also there is no backup for the datafile.
    Thanks

    Hi,
    ALTER DATABASE DATAFILE '<full file spec>' OFFLINE DROP;
    example: just give '+dg1/../../..' if it not exists also give the same
    Kind Regards,
    Rakesh Jayappa

  • ORA-03264: cannot drop offline datafile of locally managed tablespace

    Hi list
    A datafile was acidentally created on filesystem in one node of two nodes RAC.
    After that the filesystem on which the datafile was created was out of space because of automatic control file backup and sysadmin move this datafile to another device. And before this action RMAN backup stopped work.
    Now we replace the datafile to the original location, but it stay offline and recover status, and we cant bring them online because the customer dont have necessary archive logs to recover this datafile. RMAN backup is now working. But now we need to create a DataGuard on a third server and want to drop this datafile.
    This datafile dont have any data segment and stay in most critical tablespace of the customer application which have more datafiles. This datafile in question isnt the first datafile of the tablespace.
    SQL> select file#, status from v$datafile where name='/oracle/product/db/ars/dbs/arsystem.old';
    FILE# STATUS
    21 RECOVER
    SQL> select file#, status from v$datafile_header where name='/oracle/product/db/ars/dbs/arsystem.old';
    FILE# STATUS
    21 OFFLINE
    How can I drop this datafile?
    Thanks
    Cristiano

    Review this metalink note, what to do:
    How to 'DROP' a Datafile from a Tablespace
    Doc ID:111316.1
    If you cannot recover the datafile, you have to export the 'rest' of the tablespace (after statement 'alter database datafile '/oracle/product/db/ars/dbs/arsystem.old' offline drop;' was successfully issued). Afterwards drop the tablespace,recreate it and import the data).
    Werner

  • Drop offline Datafile

    Oracle Database version - 10.2.0.3
    I have a tablespace with 2 datafiles. One of the datafile is offline since couple of months. Now I am trying to drop the offline datafile but its not possible to drop that datafile.
    As its production environment I can not take the tablespace in offline mode.
    Can anyone please suggest suitable solution to drop the datafile?
    Regards,
    Sandeep

    SQL> alter tablespace AUDIT_REPORT drop datafile '/data/zus26d-0701/oracle/u04/PZHINF01/cust_idx_04.dbf';
    alter tablespace AUDIT_REPORT drop datafile '/data/zus26d-0701/oracle/u04/PZHINF01/cust_idx_04.dbf'
    ERROR at line 1:
    ORA-03264: cannot drop offline datafile of locally managed tablespace
    SQL>

  • How to drop the datafile?

    Hello Everybody
    is it possible to drop the datafile? i have run the query ALTER DATABASE DATAFILE 'c:\oracle\oracle_db\m300\user\user01.dbf' offline drop. After i checked with DBA_DATA_FILES its there.Can any one help in this regards
    Regards
    Hameed

    Please see this link:
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14231/dfiles.htm#i1006556
    Restrictions for Dropping Datafiles
    The following are restrictions for dropping datafiles and tempfiles:
    The database must be open.
    If a datafile is not empty, it cannot be dropped.
    If you must remove a datafile that is not empty and that cannot be made empty by dropping schema objects, you must drop the tablespace that contains the datafile.
    You cannot drop the first or only datafile in a tablespace.
    This means that DROP DATAFILE cannot be used with a bigfile tablespace.
    You cannot drop datafiles in a read-only tablespace.
    You cannot drop datafiles in the SYSTEM tablespace.
    If a datafile in a locally managed tablespace is offline, it cannot be dropped.
    Regards

  • Dropping a Datafile and Deleting its References

    Using sqlplus how do I delete datafiles and any references to them?
    At the moment I start the database in mount mode and use:
    ALTER DATABASE DATAFILE 'O:\BCS\test.ora' OFFLINE DROP;
    Which drops the datafile, but when I try to open the database it fails because it is still referencing the datafile.
    How do I delete this reference?
    Any thoughts or suggestions are greatly appreciated.
    Regards
    Toby

    I usually use the following sql to see what is in a tablespace before I drop it with
    "drop tablespace users including contents and datafiles;"
    column meg format 999999999
    column tablespace_name format a20
    set wrap off
    set lines 120
    set heading on
    set pages 50
    select round(sum(a.bytes)/1024/1024) meg,
    count(*) extents,a.tablespace_name,a.segment_type,a.owner||'.'||a.segment_name
    from dba_extents a
    where a.tablespace_name=upper('&1')
    group by a.tablespace_name,a.segment_type,a.owner||'.'||a.segment_name
    order by round(sum(a.bytes)/1024/1024)
    I also map the contents of datafiles with the following you can get the file_id from v$datafile or dba_data_files:
    column owner format a30
    column object format a30
    set lines 120
    set wrap off
    set trunc off
    set pages 50
    set feedback on
    column file_id format 999
    select     /*+ Rule */     'free space' owner     /*"owner" of free space*/
    ,          ' ' object          /*blank object name*/
    ,          file_id                    /*file id for the extent header*/
    ,          block_id               /*block id for the extent header*/
    ,          blocks                    /*length of the extent, in blocks*/
    from          dba_free_space
    where          file_id=&1
    union
    select     /*+ Rule */ substr(owner,1,20)||' '||substr(segment_type,1,9) /*owner name (first 20 chars)*/
    ,          substr(segment_name,1,32)||'.'||partition_name     /*segment name*/
    ,          file_id                    /*file id for the extent header*/
    ,          block_id               /*block id for the extent header*/
    ,          blocks                    /*length of the extent, in blocks*/
    from           dba_extents
    where          file_id=&1
    order by     3,4
    And datafiles can be dropped in 10g if they are empty:
    alter tablespace users drop datafile '/oracle/oradata/users01.dbf';
    Good luck

  • Dropping system datafile

    Dear all,
    10.2.0.4 on solaris 10
    We created some additional datafiles for system tablespace as we enabled auditing. Auditing is cancelled as per the requirement
    from management. now , out of 7 datafiles, 4 are empty.Is it safe to
    drop this datafiles .(am checking the free space of the datafile from
    toad object browser )
    Thanks
    Kai

    No. You can never drop datafiles in the SYSTEM tablespace. (You can resize them downards).
    One more reason why it is a bad idea to create objects in the SYSTEM tablespace.
    Hemant K Chitale

  • Dropping a datafile

    Can we drop one datafile from a tablspace?
    I have a tablespace TS1 which has 3 datafiles.i made one datafile offline and trying to drop that particular datafile....is it possible ?
    SQL> alter database datafile 'E:\ORACLE\ORADATA\TESTDB\KISH1.DBF' DROP;
    alter database datafile 'E:\ORACLE\ORADATA\TESTDB\KISH1.DBF' DROP
    ERROR at line 1:
    ORA-01916: keyword ONLINE, OFFLINE, RESIZE, AUTOEXTEND or END/DROP expected
    the errror is we are not giving the right option but Oracle itself is suggesting a DROP option...CAN ANYONE HELPME OUT
    THANKS

    I have tried this. If the tablespace contains objects, when you issue command
    alter tablespace <tablespace_name> drop datafile <datafile_name>;
    you will get ORA-03263
    If the tablespace is empty, you can drop the second datafile.
    It doesn't make sense to me to drop one of the datafile. You can drop the entire tablespace with "including contents and datafiles" and create another tablespace. I rarely got the situation to drop one of the datafile.

  • Can I Drop a datafile from UNDOTBS

    Hi!!!!
    I want to drop a datafile from UNDOTBS . can I Drop it.
    If yes then how to drop ? what is the effect of it on database?
    If anybody knows the the answer then Pls reply..

    You can do this provided test it before doing it in production
    Steps.
    1. Create a new Undo tablespace
    2. Shutdown the database
    3. Change the parameter UNDO_TABLESPACE to the newly created undo tablespace
    4. Start the database
    5. Do whatever you want with the old undo tablespace.

  • Accidentally dropped a Datafile

    Hi friends
    I run oracle 11.2.0.3.0 on windows machine
    I have accidentally dropped a datafile on develop DB without media recovery active, so that, I cant just turn the file offline as shown below:
    SQL> ALTER DATABASE DATAFILE 88 OFFLINE;
    ALTER DATABASE DATAFILE 88 OFFLINE
    ERROR at line 1:
    ORA-01145: offline immediate disallowed unless media recovery enabled
    What Can I do to bypass this datafile or even the tablespace that its not so important and could be lost?
    I tryed remove the tablespace without success:
    SQL> DROP TABLESPACE V_FISCO_INDX;
    DROP TABLESPACE V_FISCO_INDX
    ERROR at line 1:
    ORA-01109: database not open
    the status is mounted
    **** Can I turn on the media recovery and place the datafile offline?
    or I'll have to re-create the control file?
    If so, how?
    Thanks a lot friends

    Hi friends
    It worked now.
    SQL> alter database archivelog;
    Database altered.
    SQL> ALTER DATABASE DATAFILE 88 OFFLINE;
    Database altered.
    SQL> alter database open;
    Database altered.
    SQL> SELECT DISTINCT(OWNER) FROM DBA_TABLES WHERE TABLESPACE_NAME='V_F';
    no rows selected
    SQL> DROP TABLESPACE V_F including contents and datafiles;
    Tablespace dropped.
    SQL> SHUTDOWN IMMEDIATE
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> STARTUP MOUNT
    ORACLE instance started.
    Total System Global Area 6396977152 bytes
    Fixed Size 2265120 bytes
    Variable Size 3841986528 bytes
    Database Buffers 2533359616 bytes
    Redo Buffers 19365888 bytes
    Database mounted.
    SQL>
    SQL>
    SQL> ALTER DATABASE NOARCHIVELOG;
    Database altered.
    SQL> ALTER DATABASE OPEN
    2 ;
    Database altered.
    tks a lot.

  • Drop one datafile

    Hi,
    I have 5 datafile in one tablespace. If i want to drop perticular one datafile from the tablespace can you please suggest me some command to do this activity.
    Thank You

    Hi,
    My database version is 9i on Linux and this database in No archivelog mode.
    Is it possible to drop one datafile from one Tablespace.
    Thankx in advance.

  • Drop one datafile from Tablespace

    Hi,
    I have 9i Database on Linux. I want to drop one datafile from tablespace. I have tried to drop datafile through following command but it gave no effect.
    alter database datafile <datafile name> offline drop;
    What should i have to do for dropping datafile?
    Do the needful
    Thankx in advance.

    Hi
    since you dont specify the database version or if you have it setup as archivelog or noarchivelog mode, i paste the drop specs for dropping a datafile, from SQL Reference manual of 9i
    DROP If the database is in NOARCHIVELOG mode, you must specify the DROP
    clause to take a datafile offline. However, the DROP clause does not remove the
    datafile from the database. To do that, you must drop the tablespace in which the
    datafile resides. Until you do so, the datafile remains in the data dictionary with the
    status RECOVER or OFFLINE.
    If the database is in ARCHIVELOG mode, Oracle ignores the DROP keyword.
    Regards
    Message was edited by:
    pcambra

  • ORA 1426 when dropping a datafile.

    Hello,
    While dropping a datafile, I got the following error message:
    ORA-00604: une erreur s'est produite au niveau SQL récursif 1
    ORA-01426: dépassement numérique
    The command I used is the following:
    alter tablespace m4prod drop datafile 'd:\oradata\paie\m4prod02.dbf';
    Most of the posts I got from the net regarding that error were in reference to calling a procedure. I am not invoking any PL/SQL block so I don't understand why that error and how do I fix it.
    Thanks in advance.

    My database version is:
    select from v$version;*
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    I did not configure any trigger either on the database nor on an object.

  • Drop a datafile from physical standby's control file

    Hi,
    I am trying to create a physical standby database for my production...
    1) I have taken cold backup of my primary database on 18-Nov-2013...
    2) I added a datafile on 19-nov-2013 ( 'O:\ORADATA\SFMS\SFMS_DATA4.DBF' )
    3) Standby control file was generated on 20-ov-2013 (today) after shutting down and then mounting the primary database...
    When i try to recover the newly setup standby using archive files, i am getting the following error (datafile added on 19th Nov is missing)
    SQL> recover standby database;
    ORA-00283: recovery session canceled due to errors
    ORA-01110: data file 39: 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    ORA-01157: cannot identify/lock data file 39 - see DBWR trace file
    ORA-01110: data file 39: 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    How to overcome this situation...
    Can i delete the entry for the newly added datafile from the backup control file ?
    When i tried to delete datafile using "alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF';", it is showing that database should be  open..
    SQL> alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    ERROR at line 1:
    ORA-01109: database not open
    SQL> show parameter STANDBY_FILE_MANAGEMENT
    NAME                                 TYPE        VALUE
    standby_file_management              string      AUTO
    SQL> alter system set STANDBY_FILE_MANAGEMENT=manual;
    System altered.
    SQL> show parameter STANDBY_FILE_MANAGEMENT
    NAME                                 TYPE        VALUE
    standby_file_management              string      MANUAL
    SQL> alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    ERROR at line 1:
    ORA-01109: database not open
    Regards,
    Jibu

    Jibu wrote:
    Hi,
    I am trying to create a physical standby database for my production...
    1) I have taken cold backup of my primary database on 18-Nov-2013...
    2) I added a datafile on 19-nov-2013 ( 'O:\ORADATA\SFMS\SFMS_DATA4.DBF' )
    3) Standby control file was generated on 20-ov-2013 (today) after shutting down and then mounting the primary database..
    Hi,
    What is your version?
    If you added new datafile or created new tablespace, take backup again for restore new created standby database.
    If your standby  database running well, DG configuration success, then this datafile will create on standby side, too.
    Set STANDBY_FILE_MANAGEMENT=AUTO best practice.
    When i try to recover the newly setup standby using archive files, i am getting the following error (datafile added on 19th Nov is missing)
    SQL> recover standby database;
    ORA-00283: recovery session canceled due to errors
    ORA-01110: data file 39: 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    ORA-01157: cannot identify/lock data file 39 - see DBWR trace file
    ORA-01110: data file 39: 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    How to overcome this situation...
    Can i delete the entry for the newly added datafile from the backup control file ?
    Not need any delete datafile from standby side, you must recreate standby database, or you can  take RMAN backup and restore to standby  side again.
    When i tried to delete datafile using "alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF';", it is showing that database should be  open..
    SQL> alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    ERROR at line 1:
    ORA-01109: database not open
    SQL> show parameter STANDBY_FILE_MANAGEMENT
    NAME                                 TYPE        VALUE
    standby_file_management              string      AUTO
    SQL> alter system set STANDBY_FILE_MANAGEMENT=manual;
    System altered.
    SQL> show parameter STANDBY_FILE_MANAGEMENT
    NAME                                 TYPE        VALUE
    standby_file_management              string      MANUAL
    SQL> alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    alter tablespace SFMS_BR_DATA drop datafile 'O:\ORADATA\SFMS\SFMS_DATA4.DBF'
    ERROR at line 1:
    ORA-01109: database not open
    It is not logical, Physical  standby must be bit-for-bit same with Primary  database.
    Regards
    Mahir M. Quluzade

Maybe you are looking for