Monday, 6 July 2015

How to find and rebuild all indexes in a particular schema. This is probably the best Query out of all rebuild indexes queries to find and rebuild all indexes in a schema.

1)  Create a spool before running the following query.

spool on
spool c:\query.txt

2)  Run the following query and provide the schema name.

select 'alter index '||owner||'.'||index_name ||' rebuild online nologging;' from dba_indexes where owner=upper('SCHEMA_NAME');

3) Switch the spool off

Spool off

4) Open the spool file and copy all contents in notepad++/notepad

5) Copy the automatically generated rebuild indexes command for all objects and run in sqlplus.


Done.

No comments:

Post a Comment