DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Rebuild indexes

  1. #1
    Join Date
    Jul 2001
    Location
    Montreal
    Posts
    222

    Question Rebuild indexes

    Hi I want to move my indexes to another tablespace. (Rebuild)
    I am trying to create the script but keep getting script errors.
    Could someone please see what wrong with this script ?

    select 'alter INDEX | 'INDEX_NAME'' | 'tablespace name' 'INDX' from all_indexes where owner = 'DEV';

  2. #2
    Join Date
    Dec 2007
    Posts
    55
    select 'alter index '||index_name||' rebuild tablespace tablespace_name;' from dba_indexes where owner='XYZ'

    Regards

  3. #3
    Join Date
    Oct 2006
    Posts
    175
    Try this:
    SELECT 'alter index ' ||index_name||' rebuild tablespace '|| tablespace_name||' from all_indexes where owner= DEV'
    all_sqls from dba_indexes WHERE OWNER='DEV';

    HTH,
    gtcol

  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Nice... but you have to test your code before posting it guys

    Code below would take care of your non-partitioned indexes..
    Code:
    select  'alter index '                      || 
            owner                               ||
            '.'                                 ||
            index_name                          || 
            ' rebuild tablespace '              || 
            'YOUR_NEW_TABLESPACE;' "REBUILD INDEX COMMAND"           
    from    dba_indexes 
    where   OWNER='DEV'
    and     tablespace_name is not Null;
    If needed you may have to alter the code to rebuild ONLINE if you are planning to do it while having your database available to users.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width