script-move a list of indexes - particular set of tables in a tablespace
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: script-move a list of indexes - particular set of tables in a tablespace

  1. #1
    Join Date
    May 2002
    Posts
    193

    script-move a list of indexes - particular set of tables in a tablespace

    Dear All,

    the script that I have given below gives me a list of indexes that are there for the corresponding tables in the tablespace P1ECP1_LT96K_D. Now having got the list of indexes I would like to move the indexes to another tablespace. Can anyone modify this script so that I will be getting the script for moving the indexes to a seperate tablespace as well.

    Regards,

    K.Diwakar


    select
    'select index_name from dba_indexes where table_name=''' ||table_name|| ''';'
    from dba_tables where tablespace_name='P1ECP1_LT96K_D' and owner='DIP_S01' ;

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253

    Re: script-move a list of indexes - particular set of tables in a tablespace

    H'mmm. I suspect you didn't try hard to solve this yourself, but anyway ...

    Code:
    select
       'Alter index '||owner||'.'||index_name||' rebuild tablespace my_tablespace;'
    from
       dba_indexes
    where
       (owner,table_name) in 
          (
          select
             owner,table_name
          from
             dba_tables
          where
             tablespace_name = 'P1ECP1_LT96K_D' and
             owner = 'DIP_S01'
          )
    /
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    May 2002
    Posts
    193
    Hi Slimdave,

    I was just breaking my head in the next step (after what I had posted) but just got stuck on that. Your reply is helpfull to a great extent in solving the problem.

    Could you point out the mistake/edit what I have given below if I have proceeded in the correct way:


    select
    'select
    'alter index' ||index_name|| 'move tablespace P1ECP1_LT96K_X ;'
    from dba_indexes where table_name='''||table_name||''';'
    from dba_indexes where tablespace_name='P1ECP1_LT96K_D'
    ;


    Thanks and Regards,

    K.Diwakar
    Last edited by diwakar; 09-25-2003 at 01:00 PM.

  4. #4
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Most likely you are getting your single quote occurances incorrect. ie. to place a literal single quote in a string you have to ...

    'beforequote''afterquote'

    ... and to nest another level inside that you have to ..

    'beforenestedstring''insidenestedstring''''stillinside''notinnestedstring'

    This is really because you are writing a SQL to generate a series of SQL's that then generate another series of SQL's -- the example i gave just "jumps" straight down to the lowest level in one go.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  5. #5
    Join Date
    Oct 2002
    Location
    Ljubljana,Slovenia
    Posts
    28
    You can't MOVE indexes to another tablespace. You have to REBUILD indexes to move them!

    Correct :
    SELECT
    'ALTER INDEX ' || index_name || ' REBUILD TABLESPACE P1ECP1_LT96K_X;'
    FROM dba_indexes WHERE tablespace_name='P1ECP1_LT96K_D';
    Aleš Orehek

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