Deleting a datafile

In Oracle8i, how does one delete or drop a datafile? The file does not physically exist on disk. When I try to "create tablespace datafile 'foo' size 100m", it reports that it cannot process the statement because the "datafile already exists". It seems that I need to tell Oracle to delete the datafile before I can recreate it.

The "and datafiles" is not supported in 8i. Believe it or not, I think the prescribed method of deleting datafiles is to do so at the OS prompt (gulp!). Seems strange since Oracle creates the datafile via an SQL command (create tablespace <foo> datafile <fname>).

Similar Messages

  • Delete a datafile in 11gR2 ASM

    Here is the current datafiles of the database 11gR2, 11.2.0.1 on the ASM file system.
    SQL> select FILE_NAME,TABLESPACE_NAME from dba_data_files;
    FILE_NAME TABLESPACE_NAME
    +DATA01/heat/datafile/testtbs.274.807968419             TESTTBS
    +DATA01/heat/datafile/testtbs.266.807968493             TESTTBS
    +DATA01/heat/datafile/testtbs.258.807968511             TESTTBS
    1/ Use RMAN to backup the whole db onto the disk
    2/ In RMAN, check the backup: List backup; See all the backup including the above data files;
    3/ Run this cmd to drop 1 datafile, In SQL> ALTER TABLESPACE TESTTBS drop datafile '+DATA01/heat/datafile/testtbs.258.807968511';
    4/ Verify it, whether that data file deleted, yes it was deleted.
    SQL> select FILE_NAME,TABLESPACE_NAME from dba_data_files;
    FILE_NAME TABLESPACE_NAME
    +DATA01/heat/datafile/testtbs.274.807968419             TESTTBS
    +DATA01/heat/datafile/testtbs.266.807968493             TESTTBS
    5/ In RMAN, check the backup again: List backup; It's not there in the backup. Why's that ?????????????????????
    BS Key Type LV Size Device Type Elapsed Time Completion Time
    6 Full 935.09M DISK 00:01:15 21-FEB-2013 11:43:44
    BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20130221T114228
    Piece Name: +FRA01/heat/backupset/2013_02_21/nnndf0_tag20130221t114228_0.344.807968549
    List of Datafiles in backup set 6
    File LV Type Ckp SCN Ckp Time Name
    1 Full 999944 21-FEB-2013 11:42:29 +DATA01/heat/datafile/system.256.807898985
    2 Full 999944 21-FEB-2013 11:42:29 +DATA01/heat/datafile/sysaux.261.807898985
    3 Full 999944 21-FEB-2013 11:42:29 +DATA01/heat/datafile/undotbs1.260.807898985
    4 Full 999944 21-FEB-2013 11:42:29 +DATA01/heat/datafile/users.268.807898985
    5 Full 999944 21-FEB-2013 11:42:29 +DATA01/heat/datafile/testtbs.274.807968419
    6 Full 999944 21-FEB-2013 11:42:29 +DATA01/heat/datafile/testtbs.266.807968493
    7 Full 999944 21-FEB-2013 11:42:29
    6/ Try restore the deleted data file, it's not available in the backup ????? I do not understand this ? Really appreciate someone could explain this ?????

    When you drop a datafile, the database instance updates controlfiles, redologs and SCN numbers. The datafile you have in your backup will no longer match the the rest of the database environment, so it cannot be restored without restoring the complete database prior to the time the datafile was dropped. Similarly you cannot mount or restore the datafile of a different database. The database does not maintain recovery information for a datafile that does not exist. If you loose the datafile, e.g. delete it from the filesystem, you can restore the datafile and recover the information using the existing controlfile and redologs. That is all normal and is not influenced by ASM.

  • Delete the datafile

    Hi all,
    I want to delete Datafile from my ASM instance. I gave a bad name to my data file and i want to remove it now.
    SQL> select file_name,TABLESPACE_NAME,ONLINE_STATUS from dba_data_files where TABLESPACE_NAME ='USERS';
    FILE_NAME TABLESPACE_NAME ONLINE_STATUS
    +DATA/orcl/datafile/users2           USERS                RECOVER
    Please help me to resolve this issue.
    Thanks,
    krish

    user2281943 wrote:
    Hi all,
    I want to delete Datafile from my ASM instance. I gave a bad name to my data file and i want to remove it now.
    SQL> select file_name,TABLESPACE_NAME,ONLINE_STATUS from dba_data_files where TABLESPACE_NAME ='USERS';
    FILE_NAME TABLESPACE_NAME ONLINE_STATUS
    +DATA/orcl/datafile/users2           USERS                RECOVER
    You can NOT delete datafiles once they are part of the database.There is a command to drop the datafile but that works only when the file is completely empty. For your "bad name" issue of te file, all what you needed to do was to use the Rename command and to rename the file. But what appears is that the file is either offlined or is not available. Do you have archivelog mode enabled and have all the archivelogs with you? What appears is that you need to recover the said file before you can do anything else over it.
    HTH
    Aman....

  • Deleted undo datafile before dropping the tablespace.

    i had accidently deleted a undo datafile which was no more needed before dropping the tablespace.
    i started up the database in mount stage by making that datafile offline.
    now while dropping the database it is giving an error.
    SQL> drop tablespace UNDOTBS1 ;
    drop tablespace UNDOTBS1
    ERROR at line 1:
    ORA-01548: active rollback segment '_SYSSMU1$' found, terminate dropping tablespace
    Do someone have a resolution. I dnt need this tablespace anymore.

    http://www.my-whiteboard.com/oracle-dba/how-to-drop-and-recreate-oracle-undo-tablespace-and-its-data-files.html may be helpful to you.

  • Automatic deleting of datafiles after DROP TABLESPACE

    Lazy junior dba question. How can i order oracle to delete files automaticly after deleting them from control file (like drop tablespace command)?
    What technology/approach should I use? Can ASM help me?
    Thnaks.

    Well, ideally after issuing
    DROP TABLESPACE <TBS_NAME> INCLUDING CONTENTS AND DATAFILES; the datafiles corresponding to that tablespace should get deleted automatically. Although, in my case, sometimes it gets deleted automatically, but sometimes it doesn't(Windows Server).
    Comments from others will be useful.
    Regards,
    Anand

  • RAC - DBCA -silent deleteDatabase not deleting underlying datafiles

    Hello All,
    I have a small question. I recently deleted a RAC database on 11GR2 (Grid Infrastructure) using the following command as the database owner (oracle)
    dbca -silent -deleteDatabase -sourcdDB mydb -sysDBAPassword mypassword -sysDBAUserName sysThe command execute properly. But I see the datafile structure is still under ASM. I'm wondering if the command should have been run as grid rather then oracle, because the documentaiton states:
    http://docs.oracle.com/cd/E11882_01/install.112/e10813/dbcacrea.htm#BABIGJAH
    "At this point, you have accomplished the following:"
    Deleted the selected database from the cluster
    Deleted high availability services that were assigned to the database
    Deleted the Oracle Net configuration for the database
    Deconfigured Database Control for that database
    Deleted the OFA directory structure for that database from the cluster
    Deleted the data files if the data files were not on raw devices
    Thanks in advance for your advise and assistance.
    Jan S.

    Check with this doc
    Removing a Node from a 10gR1 RAC Cluster [ID 269320.1]
    regards,
    Shaan

  • Delete Temp Datafiles

    Hi all,
    The temporary tablespace datafiles were old and occupy lot of space. Can I safely remove them or shall I backup them to disk.
    Thanks.

    786923 wrote:
    Hi all,
    The temporary tablespace datafiles were old and occupy lot of space. Can I safely remove them or shall I backup them to disk.
    Thanks.Do not need backup of temp tablespace,but you can create new temporary tablespace and delete old ts as
    create temporary tablespace new_tempts tempfile 'tempfile_full_path'  size <size> autoextend on next 30M;
    alter database default temporary tablespace  new_tempts;
    drop tablespace old_ts_name;

  • Someone deleted my datafile...

    On windows
    oracle 10.2
    I just created the database. It is for development purposes. Ther eis nothing in it I can't afford to lose. I don't have a backup.
    I just want to drop the tablespace with the datafile in it.
    1. I can mount the database, but can't open it because oracle can't find the datafile
    2. i cant drop the tablespace in mounted mode.
    I know there is a way to fix this. what do I do? I know I need to somehow drop the tablespace.

    Do alter database backup controlfile to trace;
    Then recreate you controlfile using the file created by the command above. Remove reference for your missing datafile from this create controlfile script. The script in a form of trace file willl be in your .../udump directory. You will need to remove your control files (you may save them someplace).
    Let me know if you have further questions. Good luck.
    Greg

  • Help! datafile deleted on oracle 9i under redhat linux

    Please help me, i delete a datafile from a test tablespace and i don't know
    how to fix it on 9i, in 8i is very documented but 9i is a real pain, here
    is the error when 'dbstart'ing the db:
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    SQL> Connected to an idle instance.
    SQL> ORACLE instance started.
    Total System Global Area 353440004 bytes
    Fixed Size 450820 bytes
    Variable Size 167772160 bytes
    Database Buffers 184549376 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    ORA-01157: cannot identify/lock data file 28 - see DBWR trace file
    ORA-01110: data file 28: '/oradata/alumnos/tablespaces/test2.dbf'
    Thank you in advance,
    Otto Solares

    Can you perform a Tablespace Point In Time Recovery on the specific tablespace?

  • Why the query of the object still can work after the datafile has been deleted?

    Dear friends:
    Recently, I deleted a datafile from OS but don't touch the correspondent tablespace in OEM(actually the datafile name still exists in OEM after I deleted it from OS). I found out I still can create objects such as table and query it in this tablespace using sqlplus though the physical datafile has already been deleted.(What I done is I created new objects using an account whose default tablespace is that one which I deleted the datafile from it.). Will these new objects use another datafile instead the original one deleted? I will appriciate if you can point out the reason for me. Thanks for your help!
    John
    07/26/2002

    Even though you delete a datafile physically from OS, entries about the datafile still exists in Data Dictionary. So long as these entries are there in data dictionary, Oracle will consider that these file exists unless there is a specific command which referes to deleted files.
    Further, you are trying to create table in a tablespace whose datafile is deleted. If that was the only datafile for that tablespace then you should get an error. If the table is getting created, there must be some other datafile for that tablespace, in which your table is getting created. This is all when your database is already in running stage. If you shutdown and restart the database, it won't start next time because of missing datafile.
    Hope this solves your query.

  • How to recover to keep tablespaces working after datafile deleted on OS

    hi,
    given situation like this :
    1. OS HPUX 11i
    2. Oracle 9.2 or 10g
    3. tablespace AAA have a datafile AAA.dbf
    4. AAA.dbf has been deleted by a guy on OS by accident
    5. it's a production database , i have other copy of product running elsewhere
    6. we can forget about the data on this tablespace , just wanna make sure new data will still be inserted
    I know there is a magic way involving file descritpor to recovery the file on OS if it was still opened by the process
    seems it only works on linux or solaris , since HPUX don't have /proc
    here is what i had done ,
    1. offline drop the tablespace
    2. export tablespace AAA from other DB without data but everything else
    3. import them into DB without AAA now
    only problem seems application couldn't insert into the tables ,Object priveledge not granted
    i'd checked the export file , those object grant SQL are right there , i just don't know why import hasn't worked
    so my question is
    if it were you ,
    1.do you have any better idea of how to recover
    2.if you any dirty and fast way of recovery File on HP box , appreciate that too
    3.can you image why import doesn't seems getting priveledge imported ? my DB version 9.2.0.4
    many thanks
    br/ricky

    thanks , aman ,lenord and you all
    looks like i'm the sinful :)
    to clear it up ... it's not me who did it , one of our guys , same thing ,hum ~~
    he deleted the backup , cause it's full and auto backup is not ongoing , and he's trying to make things right
    he deleted the datafile , cause i told him to rename the file to another space , coz vgdb is full , screw up that too ..
    yeah , it'a real production database ~~ , so ,if anybody learn somethings on this , credit on me , :)
    the version is 9.2.0.4 , but gonna move to 10g soonor or later , so put it there , to see if in 10g , we can do better ..
    tablespace created like five years ago , so , apply all archive since would be crazy ~
    this database have 500 Tablespaces , and thoudsands of tables , and the one lost is a important one ,
    but data in it , we can bear loss
    what i do , is offline drop the tablespace , and import the tablespace without data from other production DB ...
    only it didn't work out so well with object grant , and application still not inserting ...
    why i post it here , is i wanna learn better ways in this kind of situations ...
    i thought my way is not good enough
    anway , i'll look at all your suggestions
    thanks
    br/ricky
    Edited by: zs_hzh on Sep 15, 2008 10:12 PM

  • Datafile deleted

    hi
    by mistake i have deleted one datafile.. is there any way to bring up the db
    actually i have created a perfstat tablespace with 1 datafile named perfstat.dbf in two database
    latter on that tablespaces was not required so i was tried to drop the tablespace
    so i started with the 1st database and drop the tablespace using
    drop tablespace <tsname> including contents and datafiles
    by mistake i have open the another database folder where all the datafile is located...i found that perfstat datafile is not deleted so i have deleted it using os command rm ( so by mistake i have fired drop tablespace command in 1st database and physicaly deleted the file from another database)
    the problem is we dont have backup and our database is in no archivelog mode
    currently db is running but whenever we will restart db it will give us error about this file and db wont up
    so is there any workaround for this..... plz its urgent.

    hi alok
    r u sure this will work because.. datafile is not there it is deleted.. currently db is running and if i m trying to offline tablespace it is giving me this error
    SQL> alter tablespace perfstat offline;
    alter tablespace perfstat offline
    ERROR at line 1:
    ORA-01116: error in opening database file 6
    ORA-01110: data file 6: '/td_oradata/oradata/p012band/perfstat.dbf'
    ORA-27041: unable to open file
    HPUX-ia64 Error: 2: No such file or directory
    Additional information: 3
    if i m trying to offline datafile it is giving me this error
    SQL> alter database datafile '/td_oradata/oradata/p012band/perfstat.dbf' offline;
    alter database datafile '/td_oradata/oradata/p012band/perfstat.dbf' offline
    ERROR at line 1:
    ORA-01145: offline immediate disallowed unless media recovery enabled
    r u sure that after shutdown the database in mount mode i can offline tablespace
    please reply

  • Delete datafile

    Hi,
    In my database, when i drop any tablespace by using following command, tablespace can be deleted by datafiles are in oradata directory and when i tried to delete manually os does not give permission to remove datafiles and os gives the error that these files are in used.
    Please help me to drop datafiles.
    Thank in advance.
    Anand.

    If you want to get rid of the datafiles, use the
    statement:DROP TABLESPACE
    tablespace_name
    INCLUDING CONTENTS AND DATAFILE;
    Depends on the database version you are using -the
    AND DATAFILES option was only introduced in 10g.
    Windows seems to be worse for this than unix. For
    some reason oracle on unix seems a lot better at
    tidying up after itself when you drop a
    tablespace...
    cheers,
    MarkThis is incorrect. "Add datafiles" exists in 9i. I
    have found that is doesn't function properly in 9i.
    Everytime I have used it, it doesn't delete the
    files. When I tried to delete them, it tells me
    they were in use, and I had to wait for a restart to
    clear the files.ok fine - I amend my statement to ADD DATAFILES exists in 9i but didn't work until 10g. ok? ;-)
    Personally I wouldn't use OEM for this kind of activity but that's personal preference...

  • Datafile Deleted but Data Accessible

    Hi
    My database is in archive log mode, 10.2.0.2.
    I took a hot RMAN backup and then created a tablespace with one datafile and created a user having this new tablespace as a default tablespace. Created two tables for this user.
    Then I deleted the datafile of this tablespace using OS command but the data is the datafile is still accessible. Isn't it strange? I thought the database will crash or will at least not access the data on this datafile.
    Can someone please tell me how this data is being accessed?
    Also if I do shutdown immediate I get the following:
    SQL> shutdown immediate;
    ORA-01116: error in opening database file 9
    ORA-01110: data file 9: '/oracle/oradata/gptest/surrey.dbf'
    ORA-27041: unable to open file
    IBM AIX RISC System/6000 Error: 2: No such file or directory
    Additional information: 3
    Thanks in Advance

    Hi
    My database is in archive log mode, 10.2.0.2.
    I took a hot RMAN backup and then created a
    tablespace with one datafile and created a user
    having this new tablespace as a default tablespace.
    Created two tables for this user.
    Then I deleted the datafile of this tablespace using
    OS command but the data is the datafile is still
    accessible. Isn't it strange? I thought the database
    will crash or will at least not access the data on
    this datafile.
    Can someone please tell me how this data is being
    accessed?
    how did you access the data? i think it takes some time to register in the control file that a daatfile has been deleted then latre if u query from that tablepsace will result in error.you can access once the deletion info is registered in controlfile.
    correct me if i am wrong
    Also if I do shutdown immediate I get the following:
    SQL> shutdown immediate;
    ORA-01116: error in opening database file 9
    ORA-01110: data file 9:
    '/oracle/oradata/gptest/surrey.dbf'
    ORA-27041: unable to open file
    IBM AIX RISC System/6000 Error: 2: No such file or
    directory
    Additional information: 3
    Thanks in Advance
    the above surrey.dbf is the one you have deleted now you need to restore and recover the datafile inturn the database.
    cheers
    maran

  • Datafile deletion

    hai
    how to check how much amount of space in a tablespace is assigned to the database user.i queried dba_ts_quotas and queried users and size columns to findout the space assigned for a user in a tablespace but the size is displayed as 0 in the size column
    please say me how to find out the space assigned for a user in a specific tablespace
    also say me whether it is possible to delete on of the 2 datafiles in a specific tablespace.if possible plesa say me how to do that
    Regards
    amberson

    "You can not delete a datafile from a tablespace."
    Really ?
    SQL> alter tablespace users add datafile;
    Tablespace altered.
    SQL> select file_id from dba_data_files where file_name like '%users%';
       FILE_ID
             4
             7
    SQL> select count(*) from dba_extents where file_id = 7;
      COUNT(*)
             0
    SQL> alter tablespace users drop datafile 7;
    Tablespace altered.
    SQL> select file_id from dba_data_files where file_name like '%users%';
       FILE_ID
             4

Maybe you are looking for