Sie sind auf Seite 1von 5

http://www.oracle-dba-online.com/tablespaces_and_datafiles.

htm

SELECT *

FROM

dba_data_files

WHERE

tablespace_name = 'TABLESPACE';

select 'rm '||file_name

FROM dba_data_files

where tablespace_name IN

('OL_SEG', 'SMSH_SEG', 'SMSAPP_SEG', 'USER_SEG', 'SMS_SEG',

'TEST_SEG', 'CHKREG_SEG', 'AR_SEG', 'GEN_SEG', 'IP_SEG',

'SL_SEG', 'MP_SEG', 'CSP_SEG', 'FOF_SEG', 'STARSHIP_SEG');

select 'rm '||file_name FROM dba_data_files WHERE


tablespace_name IN('OL_SEG', 'SMSH_SEG', 'SMSAPP_SEG', 'USER_SEG',
'SMS_SEG', 'TEST_SEG', 'CHKREG_SEG', 'AR_SEG', 'GEN_SEG', 'IP_SEG',
'SL_SEG', 'MP_SEG', 'CSP_SEG', 'FOF_SEG', 'STARSHIP_SEG');

note the formating Major commands are on a new line (select, from, where...)

1.get a list of the 'rm ' records that the select above produces and save to a file first

2.then drop the tablespaces

3.then at the linux prompt past the rm commands that you saved to delete the datafiles.

SQL> select 'rm '||file_name FROM dba_data_files WHERE

tablespace_name IN('OL_SEG', 'SMSH_SEG', 'SMSAPP_SEG', 'USER_SEG',


'SMS_SEG', 'TEST_SEG', 'CHKREG_SEG', 'AR_SEG', 'GEN_SEG', 'IP_SEG',
'SL_SEG', 'MP_SEG', 'CSP_SEG', 'FOF_SEG', 'STARSHIP_SEG');

'RM'||FILE_NAME

--------------------------------------------------------------------------------

rm /u01/oradata/starship/AR_SEG.dbf
rm /u04/oradata/starship/CHKREG_SEG.1.dbf

rm /u02/oradata/starship/CSP_SEG.1.dbf

rm /u04/oradata/starship/GEN_SEG.1.dbf

rm /u05/oradata/starship/IP_SEG.1.dbf

rm /u02/oradata/starship/MP_SEG.1.dbf

rm /u01/oradata/starship/SL_SEG.1.dbf

rm /u04/oradata/starship/SMSAPP_SEG_.1.DBF

rm /u05/oradata/starship/SMSH_SEG.1.dbf

rm /u01/oradata/starship/SMS_SEG.1.dbf

rm /u03/oradata/starship/USER_SEG.1.dbf

'RM'||FILE_NAME

--------------------------------------------------------------------------------

rm /u04/oradata/starship/TEST_SEG.1.dbf

rm /u02/oradata/starship/OL_SEG.1.dbf

rm /u02/oradata/starship/OL_SEG.2.dbf

rm /u03/oradata/starship/FOF_SEG.1.dbf

15 rows selected.

How Drop Tablespace and Recover Oracle Database When Accidentally Delete Datafile
Accident may happens, even though it’s costly one. This is especially the case in Oracle
database, which stores the database objects physically in data files on hard disk. Fast hand
administrators may accidentally delete some of the datafiles, or the datafiles may get
corrupted or unreadable on hard disk failure. You may get also some missing datafiles
after database recovery process. In any case, missing a or a few datafiles will cause Oracle
database to fail to startup, rendering the whole DB inaccessible.

The solution to the missing datafiles is to drop the affected tablespace where has
incomplete datafiles, and then recreate the tablespace and import the data into the
tablespace from backup. However, the steps are not so straight forward.

1. Run SQL

*Plus.

2. Connect to database as SYSDBA with this query:

CONNECT / AS SYSDBA

3. Mount the database instead of starting it up:

STARTUP MOUNT;

4. Issue the following command to bring the missing datafile offline so that Oracle
won’t trying to connect and access the datafile anymore:

ALTER DATABASE DATAFILE ‘<datafile name with complete path>’


OFFLINE DROP;

Repeat the command for every datafiles that unaccounted for.

5. Now start the database proper:

ALTER DATABASE OPEN;

6. As the tablespace has damaged, drop it to recreate from fresh backup.

DROP TABLESPACE <tablespace name> INCLUDING CONTENTS;

7. Ensure the other datafiles for the tablespace has been deleted, if not, remove them
manually from the operating system.

Tip: How to check datafiles that belong to tablespace.

8. Continue with the recovery


process.

http://it.toolbox.com/wiki/index.php/Delete_datafile_from_Tablespace

Sometime we need to delete datafiles belongs to a Tablespace in this case we can not do this as
simple way it should be. Unfortunaly we need to do drop the entire tablespace. But since you may
not want to lose the information in the tablespace before dropping it, take an export backup of the
tablespace info, drop the tablespace, recreate tablespace and import back.
[edit]
Steps
You need to drop the entire tablespace.
[edit]
Examples
DROP TABLESPACE PSAPGETRD
INCLUDING CONTENTS AND DATAFILES;
The above example dropped a tablespace and deletes all associated operating system datafiles.
[edit]
Conclusion
http://it.toolbox.com/wiki/index.php/Category:Oracle-db-l

http://it.toolbox.com/wiki/index.php/Category:Database_HOWTOs

http://it.toolbox.com/wiki/index.php/Category:Database_Development

http://www.gc.maricopa.edu/business/oracle/docs/Oracle80Docs/doc/database.804/a5839
7/toc.htm

Das könnte Ihnen auch gefallen