Put your tips and tricks online - Share your knowledge! Login | Register
 
 
  Search     Advanced search
 

Home | Ask Question | Add tip | Questions | My tips | Recent tips & tricks | Suggest a category | FAQ | Forums

 
 
 
 Category : Home > Databases > Oracle     

Database copy / restore - skipping tablespaces


Sometimes you want to copy (refresh) database without some tablespaces i.e. due to space
restrictions. These are general guidlines for skipping tablespaces when copying a database
(the same with RMAN restore, restore from cold backup or copy from a standby database).

1. Once the datafiles have been copied / restored

SQLPLUS> startup mount;

Run a rename datafile script if necessary

2. Use the script below to generate a drop datafile script

set head off pagesize 0 linesize 150
set echo off verify off feedback off

spool drop_files.sql

select 'set echo on verify on feedback on head on'
from dual
/

select 'spool drop_files.log'
from dual
/

--
-- This assumes that the names of your data files include
-- part of tablespace name
--
select 'alter database datafile ''' || name || ''' offline drop;' 
from v$datafile 
where name like '%SKIPPED_TABLESPACE%'
/

select 'spool off'
from dual
/

spool off

3. Run drop_files.sql script

SQLPLUS> @drop_files.sql

At this stage if you query v$datafile you will still see the files you've just dropped because
the tablespaces are still in the data dictionary, just ignore that.

4. Open the database

SQLPLUS> alter database open resetlogs;

5. Drop tablespaces that were skipped during restore

SQLPLUS> drop tablespace SKIPPED_TABLESPACE including contents;


  Options
 
   del.icio.us  |  newsvine  |  digg  |  furl  |  google  |  yahoo  |  Ma.gnolia  |  vigillar  |  reddit  |  technorati  |  icerocket  |  pubsub

     (Average: 4 / Votes: 1)   Rate this tip:    

Start discussion or add comment to this tip

  Details
Tip reference : #52
views : 2462
Added on : 11/14/05
Submited by : h8dk97
 
Send a message Send a message Printer friendly output Printer friendly output
Display this member's tips Display this member's tips (202)
 
 
<< Previous Next >>
 Most viewed tips 
  Databases > Oracle > Security : How to unlock Oracle user account  
  Databases > Oracle > Performance Tuning : How to enable trace in Oracle  
  Operating Systems > Unix : How to kill Unix user session  
  Databases > Oracle : Kill user session  
   
  All categories
Databases | Programming | Hardware | Operating Systems | Networking | Internet | ERP / CRM | Games & Multimedia | Graphics & Design | Miscellaneous | Mobile Phones / Tablets | Office Software
 
 

Home |  FAQ |  Terms of Use |  Privacy Policy

© 2005 tiplib.com