Drop datafiles
HI,
Oracle 10.2.0.4 SUSe 10 Archivelog mode
The datafile mount point is 100% used. So I had to shutdown the DB and mount it. I want to make some space in the mount space and delete unwanted datafiles from the database. Since now i am in mount stage how can i delete the datafiles from the DB. And make space on the server.
Please suggest
hi,
post
select file_name,tablespace_name,user_bytes/10024/1024,bytes/1024/1024,maxbytes/1024/1024 from dba_data_files;check for any used datafiles, if you really you dont want you can go ahead to dellete,
drop tablespace tbs1 including contents and datafiles;Thanks
Similar Messages
-
Can I drop datafiles individually, or do I need to drop the entire tablespace? The ALTER TABLESPACE command doesn't appear to have a drop datafile clause. I've dropped enough objects in the tablespace to reduce the amount of space used to 1%, but there are still a dozen objects including tables and indexes. There are also references to and from these objects to objects in other tablespaces.
Kevin TysonALTER DATABASE dbname
DATAFILE filename OFFLINE DROP;
Does not actually drop datafiles. It only takes them offline if the database is in noarchivelog mode.
However, that section in the SQL reference goes on to say...
"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. "
Which answers my question. -
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. -
Hi,
I have accidently dropped SYSAUX datafile... How can I recover it?
I used " ALTER DATABASE DATAFILE ‘<datafile name with complete path>’ OFFLINE DROP;" to drop the datafile...
Please suggest me...
Thanks
KSGThe first question I would like to have been answerred is the fact if the datafile still exists on the filesystem ? The second question would be if you are running in archive log mode ? If so you could try the following approach, if no archive logs are there and no backup:
- The alter database command has only removed the entry from the controlfile, so the datafile is only missing there as an administrative problem.
- alter database backup controlfile to trace; (trace file containing the controlfile create script)
- add in the script the dropped datafile.
- Bring down the database with an shutdown immediate
- make a backup from the whole database (just to have your start position always there !!)
- run the create controlfile script.
You could end up with a database which will not open due to recovery issues, but probably this is fixable.
Regards, Gerwin -
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 -
How to drop datafiles and contents
how to drop datafiles and contents without dropping tablespace?
May be this helps,
http://www.mydigitallife.info/2007/08/04/how-to-rename-or-move-oracle-tablespace-datafile-to-another-location/ -
Create standby having offline dropped datafile .
Hi,
How to deal with offline dropped datafiles on source when creating standby .
I've 4 node rac, and one tablespace offline and related bigdatafile droped offline (because of corruption).
SQL> select tablespace_name , status from dba_tablespaces order by status ;
TABLESPACE_NAME STATUS
OLD_TBS OFFLINE
SQL> select TS#,STATUS,ENABLED from v$datafile order by status;
TS# STATUS ENABLED
16 OFFLINE DISABLED
Its 4 node RAC 10.2.0.3 and ASM .
select name,TS#,STATUS,ENABLED from v$datafile order by status
+DBG1/dbname/datafile/bigfile.279.615031073
Currently I'm doing something like that
rman target /
catalog backuppiece '/oarch/backup/bigfile.279.615031073';
run{
allocate channel ch1 type disk;
SET NEWNAME FOR DATAFILE 16 TO '+DBG1';
restore datafile 16 from tag='TAG20100209T124507';
SWITCH DATAFILE 16;
release channel ch1;
and then after duplicate is end
SQL> alter database datafile 16 offline drop;
SQL> recover automatic standby database;Please advice.
Regards
GregGHi GregG,
I think there is no requirement to file the request with Oracle. :-) Please check the below testcase where I tried to simulate the scenario this time by using RMAN.
Primary Database: oraprd
Physical Standby database: oraphy
SYS @ oraprd>select tablespace_name,file_id from dba_data_files;
TABLESPACE_NAME FILE_ID
SYSTEM 1
SYSAUX 2
UNDOTBS1 3
USERS 4
TEST 5
SYS @ oraprd>select TS#,file#,STATUS,ENABLED from v$datafile order by status;
TS# FILE# STATUS ENABLED
6 5 OFFLINE DISABLED
1 2 ONLINE READ WRITE
2 3 ONLINE READ WRITE
4 4 ONLINE READ WRITE
0 1 SYSTEM READ WRITEConfigure catalog (controlfile) to exclude an offline tablespace TEST and perform the full database backup with standby control file
C:\>rman target sys/abc123@oraprd
connected to target database: ORAPRD (DBID=2633932676)
RMAN> configure exclude for tablespace 'TEST';
using target database control file instead of recovery catalog
Tablespace TEST will be excluded from future whole database backups
new RMAN configuration parameters are successfully storedprimary database backup with standby control file
RMAN> run{
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> backup database format 'c:\temp\rman_oraprd_%U.bkp';
5> backup archivelog all format 'c:\temp\rman_arch_%U.bkp';
6> backup current controlfile for standby format 'c:\temp\rman_standby_%U.bkp';
7> }
released channel: ORA_DISK_1
allocated channel: d1
channel d1: SID=9 device type=DISK
allocated channel: d2
channel d2: SID=143 device type=DISK
Starting backup at 15-JUN-12
file 5 is excluded from whole database backup <===
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\APP\XYZ\ORADATA\ORAPRD\ORAPRD\DATAFILE\O1_MF_SYSTEM_DATA_D-ORA11PRD_I-2924940358_TS-SYSTEM_FNO-1_07NDBK6A_.DBF
input datafile file number=00003 name=C:\APP\XYZ\ORADATA\ORAPRD\ORAPRD\DATAFILE\O1_MF_UNDOTBS1_DATA_D-ORA11PRD_I-2924940358_TS-UNDOTBS1_FNO-3_0ANDBK7H_.DBF
channel d1: starting piece 1 at 15-JUN-12
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00002 name=C:\APP\XYZ\ORADATA\ORAPRD\ORAPRD\DATAFILE\O1_MF_SYSAUX_DATA_D-ORA11PRD_I-2924940358_TS-SYSAUX_FNO-2_08NDBK6A_.DBF
input datafile file number=00004 name=C:\APP\XYZ\ORADATA\ORAPRD\ORAPRD\DATAFILE\O1_MF_USERS_DATA_D-ORA11PRD_I-2924940358_TS-USERS_FNO-4_09NDBK6B_.DBF
channel d1: specifying datafile(s) in backup set
including standby control file in backup set
channel d1: starting piece 1 at 15-JUN-12
channel d1: finished piece 1 at 15-JUN-12
piece handle=C:\TEMP\RMAN_STANDBY_0VNDJJR2_1_1.BKP tag=TAG20120615T123858 commen
t=NONE
channel d1: backup set complete, elapsed time: 00:00:03
Finished backup at 15-JUN-12
released channel: d1
released channel: d2
RMAN> exitBuild the physical standby database using RMAN
C:\>rman target sys/abc123@oraprd auxiliary sys/abc123@oraphy
connected to target database: ORAPRD (DBID=2633932676)
connected to auxiliary database: ORAPRD (not mounted)
RMAN>
RMAN> run{
2> allocate auxiliary channel a1 type disk;
3> allocate auxiliary channel a2 type disk;
4> duplicate target database for standby nofilenamecheck;
5> }
using target database control file instead of recovery catalog
allocated channel: a1
channel a1: SID=134 device type=DISK
allocated channel: a2
channel a2: SID=10 device type=DISK
Starting Duplicate Db at 15-JUN-12
contents of Memory Script:
restore clone standby controlfile;
executing command: SET NEWNAME
Starting restore at 15-JUN-12
file 5 is excluded from whole database backup <==
channel a1: starting datafile backup set restore
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00002 to C:\APP\XYZ\ORADATA\ORAPRD\ORAPHY\DATAFILE\O1_MF_SYSAUX_DATA_D-ORA11PRD_I-2924940358_TS-SYSAUX_FNO-2_08NDBK6A_.DBF
channel a1: restoring datafile 00004 to C:\APP\XYZ\ORADATA\ORAPRD\ORAPHY\DATAFILE\O1_MF_USERS_DATA_D-ORA11PRD_I-2924940358_TS-USERS_FNO-4_09NDBK6B_.DBF
channel a1: reading from backup piece C:\TEMP\RMAN_ORAPRD_0PNDJJN7_1_1.BKP
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=786026596 file name=C:\APP\XYZ\ORADATA\ORAPHY\ORAPHY\DATAFILE\O1_MF_UNDOTBS1_7XPWYO19_.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=786026596 file name=C:\APP\XYZ\ORADATA\ORAPHY\ORAPHY\DATAFILE\O1_MF_USERS_7XPWYN8N_.DBF
Finished Duplicate Db at 15-JUN-12
released channel: a1
released channel: a2
RMAN>start the managed recovery
SYS @ oraphy>recover managed standby database disconnect;
Media recovery complete.
SYS @ oraphy>select TS#,file#,STATUS,ENABLED from v$datafile order by status;
TS# FILE# STATUS ENABLED
6 5 OFFLINE DISABLED
1 2 ONLINE READ WRITE
2 3 ONLINE READ WRITE
4 4 ONLINE READ WRITE
0 1 SYSTEM READ WRITE
SYS @ oraphy>select thread#,sequence#,process,status from v$managed_standby;
THREAD# SEQUENCE# PROCESS STATUS
1 24 RFS IDLE
1 22 MRP0 WAIT_FOR_GAP <---------------
....archive the current log on the primary database
SYS @ oraprd>select thread#,sequence#,status from v$log;
THREAD# SEQUENCE# STATUS
1 22 INACTIVE
1 23 ACTIVE
1 24 CURRENT
SYS @ oraprd>alter system archive log current;
System altered.
SYS @ oraphy>select thread#,sequence#,process,status from v$managed_standby;
THREAD# SEQUENCE# PROCESS STATUS
1 25 RFS IDLE
1 25 MRP0 WAIT_FOR_LOG <-------- the recovery is in progress on the standby database.
....Regards,
Vaibhav -
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 VHello 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 -
How to drop datafiles in oracle 10g r2
Hi all,
Db :oracle 10.2.0.3
os:solaris 10
tablespace name: jllp_tabs01
datafile:
/ora/data001/jllp/jllp_tbs01_tbl_1.dbf
/ora/data001/jllp/jllp_tbs01_tbl_2.dbf
/ora/data001/jllp/jllp_tbs01_tbl_3.dbf
/ora/data001/jllp/jllp_tbs01_tbl_4.dbf
its has consisting of 4 datafiles, I need to drop the 2 of them perminently.
the datafile are having data.
how to drop the datafiles.
please suggest me.There is no way to drop the datafiles once they are added to the tablespace. The command given by Asif , offline drop won't actually drop the datafile but would be an indication only to Oracle that you would be dropping the entire tablespace after issuing this command. In 11g, there is a command to drop the datafile but only if it's completely empty.
HTH
Aman.... -
DROP DATAFILE in Oracle 10g Rel2
Hi,
I have dropped my test tablespace and forgot to include:
'INCLUDING CONTENTS AND DATAFILES;'
Now the tablespace is gone but the data file is ofcourse there.
If I do following:
ALTER DATABASE DATAFILE 'C:\ORACLE\ORADATA\ORABASE\TOOLS02.TOM'
OFFLINE DROP;
I get the error message:
ORA-01516: nonexistent log file, datafile, or tempfile "C:\temp\ts_test.dbf"
I checked the dba_data_files view and can not see the file.
Can I just delete the file manually or do I need to
to create a new tablespace and move the datafile to the new tablespace.
And than drop the new tablespace including datafile and contents?
ThanksHi,
>>Can I just delete the file manually ...
Yes, you can
Cheers -
Hi mates,
I dropped a newly created datafile in a tablespace that has two datafiles.
The syntax used is : startup mount;
alter database datafile 'c\oradata\ooo.df01' offline drop;
DATABASE ALTERED.
Now the datafile still shows as available in the DBA_DATA_FILES and the OEM..
What could be going wrong?
Do i need to do an os delete?
Is it not possible to drop a datafile atall?
Appreciate any response...
Cheers!!!!Hello All,
Our database is in archive log mode and we are running oracle 9i.
We had to release disk space occupied by a tablespace which is used for temporary contents. (Used as temp tablespace).
For this we have made a few datafiles in that as offline drop. As explained in the forum, the datafiles are still showing up in dba_data_files in recover state.
Hence, we decided to make the datafiles online again but now we are getting error that the file needs media recovery. We can keep the files offline.
My concern is if the database is shutdown for backup purposes, will it give error during restart? Also do we need to recover the database in that case? If yes then will only recover database command work?
Regards,
Anup -
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
ImranHi..
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 -
After offline drop datafile, v$datafile.status='RECOVER'
OS version:
[oracle@base ~]$ uname -a
Linux base.no.sohu.com 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
DB version:
SQL> select version from v$instance;
VERSION
9.2.0.1.0Here is my steps,
SQL>alter database datafile '/usr/oradata/bill/soq05.dbf' offline;
Database altered.
SQL>alter database datafile '/usr/oradata/bill/soq05.dbf' offline drop;
Database altered.Cause there is nothing errors generated, I thought the commands executed sucessfully. But it's not.
SQL> SELECT NAME,STATUS FROM v$datafile WHERE NAME='/usr/oradata/bill/soq05.dbf';
NAME STATUS
/usr/oradata/bill/soq05.dbf RECOVER
SQL> SELECT FILE#, STATUS, ERROR, RECOVER, TABLESPACE_NAME, NAME
2 FROM V$DATAFILE_HEADER
3 WHERE RECOVER = 'YES' OR (RECOVER IS NULL AND ERROR IS NOT NULL);
FILE# STATUS ERROR RECOVER TABLESPACE_NAME NAME
18 OFFLINE YES SOQ /usr/oradata/bill/soq05.dbf
[oracle@base ~]$ ll /usr/oradata/bill/soq05.dbf
-rw-r----- 1 oracle oinstall 1073750016 Aug 28 17:39 /usr/oradata/bill/soq05.dbfThe datafile haven't been droped successfully and its status changed to 'RECOVER'. Also, I can't online it now.
What should I do to make this datafile droped or at least make it online/offline? What I am worry is the database will be failed to restart because of this 'RECOVER' datafile.
Thanks very much!
SatineHey Werner,
Thanks very much for your help.
The reason I tried to drop the datafile is after I add the datafile to tablespace, I found the datafile failed to be created on the standby side because the parameter "db_file_name_convert"'s value were incorrect. When I created the datafile on primary side, the value of "db_file_name_convert" was,
SQL> select name,value from v$parameter where name='db_file_name_convert';
NAME VALUE
db_file_name_convert /home/oracle/bill/oradata/bill, /U02/bill/oradata/billIt should be VALUE='/usr/oradata/bill','/U02/bill/oradata/bill'. For now the datafile's status on standby side is,
SQL> SELECT name,status FROM V$DATAFILE where file#=18;
NAME STATUS
/U02/bill/product/9.2.0.1/dbs/UNNAMED00018 RECOVERIf the datafile on primary side could been recovered successfully, is there a way to make the datafile on standby side also correct?
Thanks
Satine -
Hello
Oracle 10.2.0.1
I have dataguard configuration with standby file management auto.
When I add a datafile, it is automatically added to standby database.
However,when I drop a datafile, it is dropped from primary database but it is not dropped from the standby database..
What is the reason for this?Also refer to the Oracle Documentation,
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_3002.htm
As in the documentation,
"DROP Clause
Specify DROP to drop from the tablespace an empty datafile or tempfile specified by filename or file_number. This clause causes the datafile or tempfile to be removed from the data dictionary and deleted from the operating system. The database must be open at the time this clause is specified.
The ALTER TABLESPACE ... DROP TEMPFILE statement is equivalent to specifying the ALTER DATABASE TEMPFILE ... DROP INCLUDING DATAFILES.
" -
I have dropped a tablespace with drop tablespace incliding contents command
Now how can i remove the datafile for that tablespace?I have dropped a tablespace with drop tablespace incliding contents command
Now how can i remove the datafile for that tablespace?Whats the oracle version?
If you used, drop tablespace tsname including contents, would drop the tablespace from the database.
You have to manually remove the datafiles from OS.
If could've used, drop tablespace tsname including contents and datafiles, would have dropped the tablespace as well as removed the datafiles from OS.
Maybe you are looking for
-
Trouble ordering book in iphoto 08
Hi Please help. I set up the entire photo album. When i click buy book, this window appears.. "Incomplete book. Your book seems to have frames on one or more pages that do not contain photos. You must either change the layout of those pages or place
-
I couldn't figure out how to use the Replace Color function in Photoshop, so I checked out Fireworks and was pleased to see it's user friendly in the extreme. The only problem is it doesn't work! First, I opened an image with a .png extension. (It on
-
Setting cross-domain cookies in Safari using iframe
Hi, I want to load url inside iframe. It works in all browsers. Except in safari browser. I have written code as On designer page <div id="containFrame" runat="server"> And on code behind protected void Page_Load(object sender, EventArgs e)
-
What does the Stop Workflow and log... action do?
I have used the stop workflow action in my SPD workflows but it doesn't seem to do what I thought it would. It doesn't stop....it goes right on to the next step! I want to be able to say if a condition is true, stop the workflow, do not go any furth
-
Why is there a color shift in attached email images?
I'm new to Firefox. I'm using a Mac OS 10.6.8. When I attach a B&W image file in my email account, and I view what I've sent the color shifts to a cyan instead of remaining neutral B&W in the original image. I've also tried to attach it in another em