DROP DATAFILE FROM A TABLESPACE

What is the difference between "ALTER TABLESPACE DROP DATAFILE ..." and "ALTER DATABASE DATAFILE ... OFFLINE DROP"?
I read the Oracle document before, it tolds me that the "ALTER DATABASE DATAFILE ... OFFLINE DROP" is not really drop data file. But, does the "ALTER TABLESPACE DROP DATAFILE ..." really drop data file?

"ALTER DATABASE DATAFILE ... OFFLINE DROP"
will take datafile offline to drop it later. In this case your control file will need to be recreated to de-link the datafile from database.
From 10g onwards you can ALTER TABLESPACE DROP DATAFILE... but in this case datafile should not contain any data in it.

Similar Messages

  • Droping a datafile from a tablespace

    I want to drop a datafile from a tablespace by using the query
    SQL> alter tablespace TS1 drop datafile 'OS path\df1';
    This query drops the datafile. But physically the datafile is present in the OS path. how to delete the datafile completely from the disk.

    Version:-
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>
    Although it's dropped on database level, I can't delete.If dropped data file from ORACLE, it deletes from OS level too. By any other processes being locked like antivirus and so on?
    SQL> select file_name from dba_data_files where tablespace_name='USERS';
    FILE_NAME
    C:\ORACLE\ORADATA\ORCL\USERS01.DBF
    C:\ORACLE\ORADATA\ORCL\USERS02.DBF
    SQL> alter tablespace users add datafile 'c:\oracle\oradata\orcl\users03.dbf' size 10m;
    Tablespace altered.
    SQL> host
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    C:\Users\bn2676>cd c:\Oracle\oradata\orcl
    c:\Oracle\oradata\orcl>dir users*
    Volume in drive C is System
    Volume Serial Number is 1853-3E21
    Directory of c:\Oracle\oradata\orcl
    02/15/2012  11:25 PM         5,251,072 USERS01.DBF
    02/16/2012  09:04 PM        10,493,952 USERS02.DBF
    02/16/2012  09:05 PM        10,493,952 USERS03.DBF
                   3 File(s)     26,238,976 bytes
                   0 Dir(s)  177,196,707,840 bytes free
    c:\Oracle\oradata\orcl>exit
    SQL> alter tablespace users drop datafile 'c:\oracle\oradata\orcl\users03.dbf';
    Tablespace altered.
    SQL> select file_name from dba_data_files where tablespace_name='USERS';
    FILE_NAME
    C:\ORACLE\ORADATA\ORCL\USERS01.DBF
    C:\ORACLE\ORADATA\ORCL\USERS02.DBF
    SQL> host
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    C:\Users\bn2676>cd c:\Oracle\oradata\orcl\
    c:\Oracle\oradata\orcl>dir user*
    Volume in drive C is System
    Volume Serial Number is 1853-3E21
    Directory of c:\Oracle\oradata\orcl
    02/15/2012  11:25 PM         5,251,072 USERS01.DBF
    02/16/2012  09:04 PM        10,493,952 USERS02.DBF
                   2 File(s)     15,745,024 bytes
                   0 Dir(s)  177,207,398,400 bytes free
    c:\Oracle\oradata\orcl>

  • Drop datafile from a offline tablespace

    We are running oracle 9.2 on windows.
    Out of the 3 datafiles in a non-system tablespace A, one datafile A-DF1 was accidently droped from the file system by our DBA.
    The other two datafiles were brought online by using the ALTER DATABASE RECOVER command by bringning the database in mount phase.
    Now we want to remove that datafile A-DF1 from the tablespace and bring that tablespace online.
    The database is not in archive mode and no cold backup was present.
    The solution that we want to try is:
    1-drop the tablespace A without dropping the datafiles
    2-create a new tablespace and reuse those datafiles
    3-assign this new tablespace to the affected user
    Would this work? Do you have any other safe solution for this problem?
    thanks
    Imran

    Hi..
    Your solution is a wrong solution.
    1. I guess, that the tablespace A won't be a empty tablespace.As, the objects are present in the tablespace you can't drop the tablespace without dropping its contents.You will have to use *DROP TABLESPACE <tbs_name> INCLUDING CONTENTS; -- This will drop all the contents.
    2. Do, you have a export backup, or any kind of backup.As the database is in no archivelog mode, you won't be able to do complete recovery.
    3. Take the datafile A-DF1 OFFLINE and keep the tablespace online. -- alter database datafile 'datafile_name' offline;
    If you don't have any kind of backup, the data is LOST.
    Anand

  • Need to drop datafile from my undo tablespace

    I have a undo tablespace and it has 2 datafiles. i would like to drop one datafile.
    befor i am droping this datafile i am going to bring this file to offline and i got this message: ORA--01145 offline immediate disallowed unless media recovery enable.
    can someone tell me how i can safly do it without any problem.
    Thanks

    An undo tablespace can be dropped like any other tablespace, but not until all transactions within the tablespace are complete. First, specify a new undo tablespace as in the previous example. To see if the tablespace has any pending transactions, run the following query:
    SQL> select rn.name, rs.status
    2 from v$rollname rn, v$rollstat rs
    3 where rn.name in
    4 (select segment_name from dba_segments
    5 where tablespace_name = 'UNDOTBS')
    6 and rn.usn = rs.usn
    7 ;

  • Drop datafile from tablespace

    I'm new to oracle.
    After I extended a tablespace I understood that it was too large.
    I've been reading about how to drop a tablespace, but I don't want to drop the entire tablespace. I just want to drop the last datafile of this tablespace.
    I know how to drop tablespaces in sapdba and brtools, but I don't know how I can drop one specific datafile (number 29) of the tablespace PSAPBTABD?
    Please Help med.
    Best regards
    Harald V

    Hello Harald,
    see please this thread:
    Re: How to drop data file?
    also the section 43. <i>How can I delete a data file that was created by mistake</i>
    in the SAP Note<i><b> 592393 - FAQ: Oracle</b></i>
    if you have Oracle 9i databases, it is not easy to drop a datafile, but in Oracle 10g
    you can drop a datafile like that:
    <b><i>ALTER TABLESPACE</i></b> <<u><i>Tablespace Name</i></u>> <b><i>DROP DATAFILE</i></b> '<<u>PATH und NAME of Datafile</u>>';
    for example,  you have a tablespace called PSAPC11 and you want to drop a datafile called dat.data15 of this tablespace, you can drop it like that:
    e.g. <b><i>alter tablespace</i></b> <u>PSAPC11</u> <b><i>drop datafile</i></b> <u>'/oracle/C11/psapc11/dat.data15'</u>
    Best regards
    Baran

  • Missing datafile from system-tablespace?

    Hello!
    We've got a major power-loss yesterday. After that our database does not start correct.
    I got the message:
    ORA-00600: Interner Fehlercode, Argumente: [kccpb_sanity_check_2], [9577], [9542], [0x0], [], [], [], []
    After that I searched the forum and recreated the controlfiles and started recover database.
    Now I always got the following error-message:
    ORA-01173:Data dictionary indicates missing data file from system tablespace
    I'm not really shure if I created another datafile for that tablespace. Even though there is no other datafile in the "oradata-directory".
    Does anyone know how to go further?
    Regards, Sascha
    Message was edited by:
    Sorehead

    Hello,
    Need help very quickly please!
    I have the same error message. ORacle 10.2.0.3 AIX 5.3 on a datawarehouse.
    I need to recover one tablespace from the database.
    I restored my system tablespace and the data tablespace on a test environment and recreated the controlfile. I recovered my database. Recover OK and when I open the database resetlogs the message is :
    Thread 1 opened at log sequence 1
    Current log# 2 seq# 1 mem# 0: /oradata5/RL_G2_1.ORA
    Successful open of redo thread 1
    Thu Feb 18 13:59:47 2010
    SMON: enabling cache recovery
    Thu Feb 18 13:59:47 2010
    Errors in file /opt/app/oracle/admin/MKT1/udump/mkt1_ora_2318672.trc:
    ORA-00704: bootstrap process failure
    ORA-00604: error occurred at recursive SQL level 2
    ORA-01173: data dictionary indicates missing data file from system tablespace
    Thu Feb 18 13:59:47 2010
    Error 704 happened during db open, shutting down database
    USER: terminating instance due to error 704
    Instance terminated by USER, pid = 2318672
    ORA-1092 signalled during: alter database open resetlogs...
    Thanks for help, production data ;)

  • Move datafile from system tablespace

    How can i move system datafile in a windows? I need to put database mount?
    Tks

    •     Shutdown the db
    •     Rename/Move the datafile using the o/s command
    •     Mount the db
    •     Alter database rename file <file 1> to <file 2>
    •     Alter database open;

  • Want to drop non-system table from system tablespace

    My system tablespace was having some user tables , so I moved those tables to user tablespace. Now that tables are showing in both the tablespaces ex. RET_OFF is showing in system as well as users tablespace I want to drop it from system tablespace only . Can I do it . plz help

    Hi Florian , plz check the below details . I am working on Oracle 11g on Windows platform.
    SQL> alter table REF_VAT_OFF move tablespace vatsoft;
    Table altered.
    SQL> select owner, table_name, tablespace_name
    2 from dba_tables
    3 where table_name='REF_VAT_OFF';
    OWNER TABLE_NAME     TABLESPACE_NAME
    KNVATCEN REF_VAT_OFF     SYSTEM
    OWNER TABLE_NAME     TABLESPACE_NAME
    KNVAT REF_VAT_OFF     VATSOFT

  • Remove datafile from database

    Hello all,
    I have a database 11.1.0.7 where I wanted to remove a datafile. The database is in archivelog.
    The first thing that I did was to make sure that no data was in the datafile. - OK
    Then, since I only wanted to remove 1 week later, I put the datafile offline - OK
    On the day (one week after putting it offline) that I was going to remove/drop the datafile from the tablespace I got an ORA- saying to put the datafile online before dropping.
    And here is my problem! The database says that the datafile needs recover :(
    Questions:
    1- If the datafile was offline, why does it need recover?
    2- Do you thing that the database will ask for all archivelogs until now to recover this datafile ?
    3- If I dont want to apply all archivelogs, can I simply remove the datafile by recreating the controlfile without this datafile?
    Thank you.

    Questions:
    1- If the datafile was offline, why does it need recover?The SCN must be alligned with the DB
    2- Do you thing that the database will ask for all archivelogs until now to recover this datafile ?I never tried that with missing archived logs so I cannot say it. Just try and you will see.
    3- If I dont want to apply all archivelogs, can I simply remove the datafile by recreating the controlfile without this datafile?The problem is that this datafile is registered in the dictionary. You cannot do it.
    Probably you got this exception:
    ORA-03264: cannot drop offline datafile of locally managed tablespace
    Cause: Trying to drop offline datafile in lmts
    Action: Try to drop file after making it onlinehttp://download.oracle.com/docs/cd/B28359_01/server.111/b28310/dfiles006.htm#ADMIN11435
    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.

  • 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

  • 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

  • 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

  • Question about ALTER TABLESPACE add/drop datafile

    Good afternoon,
    As an exercise, I created a tablespace STORETABS and added a datafile to it using the command:
    SQL> alter tablespace storetabs add datafile 'e:/storetabs3.dbf' size 50M;This step succeeded. A new file was created in the root of e: as expected.
    Following that command, I issued:
    SQL> alter tablespace storetabs drop datafile 'e:/storetabs3.dbf';
    Tablespace altered.The command succeeded. However, the file *'e:/storetabs3.dbf'* was not removed. After re-reading the documentation found at http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_3002.htm, I get the impression that removing the O/S file itself is something that always needs to be done manually.
    The question: Am I correct that there is no option to cause the "alter tablespace <tablespace> drop datafile <datafilename>" to delete the O/S file ? In other words, must the O/S file always be manually deleted as a separate step ?
    Thank you for your help,
    John.

    I believe in windows directory paths used backslash and not forward slash.
    You can argue why oracle does not give error, either while creating or while dropping ;)
    SQL> select * from v$version ;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL> select tablespace_name, file_name from dba_data_files ;
    TABLESPACE_NAME
    FILE_NAME
    USERS
    /u01/app/oracle/oradata/orcl/users01.dbf
    UNDOTBS1
    /u01/app/oracle/oradata/orcl/undotbs01.dbf
    SYSAUX
    /u01/app/oracle/oradata/orcl/sysaux01.dbf
    SYSTEM
    /u01/app/oracle/oradata/orcl/system01.dbf
    EXAMPLE
    /u01/app/oracle/oradata/orcl/example01.dbf
    SCOTT_TBS
    /home/oracle/scott_f1.dat
    6 rows selected.
    SQL> !ls -l scott_f1.dat   
    -rw-r----- 1 oracle oinstall 276832256 Sep 11 21:15 scott_f1.dat
    SQL> alter tablespace scott_tbs add datafile '/home/oracle/scott_f2.dat' size 10M ;
    Tablespace altered.
    SQL> !ls -l scott_*.dat
    -rw-r----- 1 oracle oinstall 276832256 Sep 11 21:15 scott_f1.dat
    -rw-r----- 1 oracle oinstall  10493952 Sep 11 21:18 scott_f2.dat
    SQL> alter tablespace scott_tbs drop datafile '/home/oracle/scott_f2.dat' ;
    Tablespace altered.
    SQL> !ls -l scott*.dat
    -rw-r----- 1 oracle oinstall 276832256 Sep 11 21:15 scott_f1.dat

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

  • Dropped datafile can't be removed from database

    I have a new dba on my team that mistakenly added a datafile to a tablespace in the wrong directory. When attempting to remove it he offlined it and then tried to drop it. It would not drop. He deleted the file from the file system. I am in archivelog mode and tried to recover datafile but no success.
    Oracle 10.2.0.4 on solaris 10 Any ideas?

    Try this.....from
    http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/recoscen.htm#sthref1366
    To re-create a datafile for recovery:
    Create a new, empty datafile to replace a damaged datafile that has no corresponding backup. For example, assume that the datafile ?/oradata/trgt/users01.dbf has been damaged, and no backup is available. The following statement re-creates the original datafile (same size) on disk2:
    ALTER DATABASE CREATE DATAFILE '?/oradata/trgt/users01.dbf' AS
    *'/disk2/users01.dbf';*
    This statement creates an empty file that is the same size as the lost file. The database looks at information in the control file and the data dictionary to obtain size information. The old datafile is renamed as the new datafile.
    Perform media recovery on the empty datafile. For example, enter:
    RECOVER DATAFILE '/disk2/users01.dbf'
    All archived logs written after the original datafile was created must be applied to the new, empty version of the lost datafile during recovery.
    If this does not work let us know your errors and problems.
    Regards
    Tim

Maybe you are looking for

  • Problem ical synch to icloud

    iCloud calendar acting up. Web app for icloud calendar synchs fine with ipad and iphone.  iCal on my Mac desktop doesn't synch in either direction.  Deleted icloud account on mac and installed it again.  No joy.  Constant "Calendar - Updating" messag

  • My phone is still

         I erased my phone online after is still, and I do not know where is it now. I want back - find my phone program-    Serial No: DN*******FG9 <Edited by Host>

  • 30 GB Battery LIfe when REcording

    I get about 2 hours of battery life on a fully charged 30GB iPod when recording using iTalk. Is this the best anyone else is getting? What are alternatives for recording lectures with greater battery life?

  • Odi 11g - malformed numeric constant thru view data

    Hi All, From ODI 11g in the Designer Tab - Models In the models where I have the Reverse Engineered tables. From the reverse engineered tables I select one of the table as SRC_CUSTOMER to see its data I right click and select view data I get the mess

  • Does iTunes 11 change playlist or podcast options?*

    Most of what I've read about the new iTunes, both complaints and praise, is about things that so far haven't mattered much to me--I primarily want to be sure that my existing playlists (some fairly complicated nested version) and podcast subscription