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

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

 
 
 
 Category : Home > Databases > Oracle > Replication     

Generate drop schema indexes script


I use the below script to drop indexes before running complete refresh in Oracle database.
Before dropping the indexes I run export without rows so that indexes can be re-created (get
sql script from export dump) after snapshots have been refreshed.


--
-- Replace USERNAME with the actual username
--
set head off pagesize 0 echo off verify off feedback off

spool coalesce_tablespaces.sql

select 'alter tablespace ' || tablespace_name || ' coalesce;'
from
        (select distinct tablespace_name
        from dba_segments
        where owner = 'USERNAME'
        and segment_type = 'INDEX')
/

spool off

spool drop_idx.sql

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

select 'spool log.drop_idx'
from dual
/

--
-- PV is the naming convention for primary keys
--
select 'drop index ' || owner || '.' || index_name || ';'
from dba_indexes
where owner = 'USERNAME'
and index_name not like 'PV%'
and index_name not like 'I_SNAP$%'
/

select '@coalesce_tablespaces.sql'
from dual
/

select 'spool off'
from dual
/

select 'exit;'
from dual
/

spool off

exit;


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

       Rate this tip:    

Start discussion or add comment to this tip

  Details
Tip reference : #102
views : 496
Added on : 05/10/06
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 (161)
 
 
<< Previous Next >>
 Most viewed tips 
  Databases > Oracle > Security : How to unlock Oracle user account  
  Operating Systems > Unix : How to kill Unix user session  
  Databases > Oracle > Performance Tuning : How to enable trace in Oracle  
  Databases > Oracle : Kill user session  
   
  All categories
Databases | Programming | Hardware | Operating Systems | Networking | Internet | ERP / CRM | Games & Multimedia | Graphics & Design | Miscellaneous | Office Software | TipLib FAQ
 
 

Home |  FAQ |  Terms of Use |  Privacy Policy

© 2005 tiplib.com