How to move indexes to another tablespace through script

Hi Dear,
How i can move indexes to another tablespace through a script which just gets new tablespace name, owner name and move and rebuild indexes in one go.
Thank u for your prompt Help.
Regards

Hi,
alter session set sort_area_size = 15000000;
spool index.sql
select 'alter index '||owner||'.'||index_name||' rebuild tablespace TARGET_TBS;'
from dba_indexes
where tablespace_name = 'INIT_TBS'
@index.sql
This script move and rebuild index from one tablespace INIT_TBS to an other tablespace TARGET_TBS
Hope this help you
Nicolas.

Similar Messages

  • How to move table from one tablespace to other tablespace?

    how to move table from one tablespace to other tablespace?

    887274 wrote:
    how to move table from one tablespace to other tablespace?
    alter table <table_name> move  tablespace <new_tablespace_name>;
    Rebuild the indexes; alter index <index_name> rebuild <new_tablespace_name> online;Example;:
    SQL> create table ttt( ID NUMBER PRimary key);
    Table created.
    SQL> insert into ttt values (1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select index_name, status  from dba_indexes where table_name='TTT';
    INDEX_NAME                 STATUS
    SYS_C0010863                 VALID
    SQL> alter table ttt move tablespace users;
    Table altered.
    SQL> select index_name, status  from dba_indexes where table_name='TTT';
    INDEX_NAME                 STATUS
    SYS_C0010863                 UNUSABLE
    SQL> alter index SYS_C0010863 rebuild tablespace users online;
    Index altered.
    SQL> select index_name, status  from dba_indexes where table_name='TTT';
    INDEX_NAME                 STATUS
    SYS_C0010863                 VALID
    SQL>

  • How to reorganization index in new tablespace

    How to reorganization index in new tablespace? for size? for? number of extents? or both?

    What's Oracle version?
    Why you want to reorg your index?
    You could rebuild your index
    alter index <index_name> rebuild tablespace <tablespace_name>check Jonathan's note regarding index rebuild,
    http://jonathanlewis.wordpress.com/2008/02/09/index-rebuild-10g/

  • Move index between two tablespaces

    My oracle806 database have two tablespaces,
    all indexes of my tables are in tablespace 'user_data',
    now I want to transfer the indexes into another tablespace.Who can show me one script to finish the task?
    tks in advanced.

    Hi,
    The below should help
    set pages 0
    set lines 120
    spool rebuild_index.sql
    select 'alter index '||index_name||' rebuild tablespace <new_ts_name>;'
    from user_indexes
    where tablespace_name = 'USER_DATA';
    spool off
    @rebuild_index.sql
    Regards,
    Sunil

  • How import data on one tablespace and indexes on another tablespace

    i have import dump from from database in oracle 10g as
    c:> imp userid=system/password full=y file=d:\ful.dmp log=d:\full.log
    Now i want import tables data on tablespace datatb and indexes on tablespace indextb. how i can do this job
    Thanks

    After importing the database you may move the indexes to other tablespace by rebuilding it.
    c:>sqlplus /nolog
    SQL> conn /as sysdba
    connected
    SQL> spool c:\indx_rbld.log
    SQL> select 'alter index '||owner||'.'||index_name||' rebuild online parallel tablespace <tablespace_name> nologging;' from dba_indexes where owner=<username>;
    SQL> spool off
    SQL> @c:\indx_rbld.log
    Hope following link will help you:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:901906930328
    Message was edited by:
    Santosh Kumar

  • Things to do after move tables and indexes to another tablespace

    dear friends.
    last night i move indexes and tables from tbs1 to tbs2.
    I checked:
    - valid objects, everything is ok.
    - indexes and tables was move ok.
    Anything else that i must to check ???
    Pls, could you help me ???
    Really thanks.
    chijar

    thanks to answers my friends
    is correct, i was moved tables: alter table <OWNER.TABLE> move tablespace <NEW TBS>; and my indx: ALTER INDEX <OWNER.INDEX> rebuild tablespace <NEW TBS>...
    i wanted to know what things i must to do after i applied that movement.
    I forgeted recollect statistics, but i recently do it, thanks to you.
    So... its appears that i did it ok. !!!
    Thanks
    cesar.

  • I want move indexes from one tablespace to other tablespace

    i'd like to know how i get move the index from one tablespace to other tablespace.
    Thank's
    []'s
    Vitor - Brasil

    Thank's for the answer, but i didn`t understand. May you explain better? I`m need to very much!! I want move the procedures from one tablesapce to other tablespace, because when i export the tables to one tablespace, the oracle export to other tablespace. I have to move the tables, but i dìdn`t get move the procedures!!
    Thank's
    []'s
    Vitor - Brasil

  • Move Constraints on another tablespace

    hi all!
    I have to move my constraints (PK) on another tablespace (now they are on SYSTEM tablespace)...is there a statement? ALTER ..MODIFY.....ecc.ecc
    THANKS!
    milena

    I think this question follows on from a User, Constraints and tablespaces. Basically the users had been created without a default tablespace. The constraints were then created without specifying a tablespace for the index. Result: a SYSTEM tablespace full of primary key indexes.
    I think in these days of RAID a-plenty the argument for having separate tablespaces for indexes no longer applies. So there is frequently no need to specify a tablespace when creating indexes (providing the user has a proper value for default tablespace). Of course, YMMV.
    Cheers, APC

  • How to move index

    Hi;
    The senerio is i have one table in schema A, i want to move this table to schema B (yesterday i had this question answer). Now i move my table (in schema A) to schema B... Question is:
    1. If i move table to schema B, should i move to table's index to schema B too? If answer NO, it can be couse any problem
    2. If i move table to schema B how i can move its index too?
    3. If one index created in schema A how i can move it schema B? Same way like questin 2?
    Thanks a lot
    Edited by: aaaaa on Oct 7, 2009 12:06 AM

    aaaaa wrote:
    Thanks for quick replay;
    In my case table is schema A and this tables's index is created Schema B, Should i move index to schema A? Is it neccessary?
    Yes because 2 tables in 2 differents schemas are independant objects.
    Index are only created automatically by Oracle at table creation if index are used by table constraints (primary key or unique).
    The best way is index and table in same schema?Yes.
    If i move index other schema should i give any grant?
    No if the index is created in the table schema.
    Thanks a lot

  • Oracle 11g R1: How to create indexes automatically in tablespaces?

    Hello,
    Obviously, due to maintenance and performance reasons it is better to put indexes in own tablespaces, separated from the data.
    I would like to know now whether there is a way under Oracle 11g R1 to create every index automatically in a tablespace?..or the indexes can only be created manually?
    Unfortunately i wasn't able to find any hint in the documentation or by googlin' it.
    Thanks in advance.
    Regards,
    Lars

    Hi Lars
    I wouldn't be quite so sure having a separate tablespace just for indexes is better for either performance or maintenance reasons if I were you ...
    For your enjoyment, some reasons why this simply is not true:
    http://richardfoote.wordpress.com/2008/04/16/separate-indexes-from-tables-some-thoughts-part-i-everything-in-its-right-place/
    http://richardfoote.wordpress.com/2008/04/18/separate-indexes-from-tables-some-thoughts-part-ii-there-there/
    http://richardfoote.wordpress.com/2008/04/28/indexes-in-their-own-tablespace-availabilty-advantages-is-there-anybody-out-there/
    http://richardfoote.wordpress.com/2008/05/02/indexes-in-their-own-tablespace-recoverability-advantages-get-back/
    Cheers
    Richard Foote
    http://richardfoote.wordpress.com/

  • How to move segments from one tablespace to another tablespace?

    I have created new tablespace now i want to move the old tablespace segments to new one but how?
    Please guide
    Thanks,
    Waheed.

    If it is Oracle 10g you might consider expdp and impdp and use remap_tablespace. After that you can purge the objects from the old tablespace.
    Throught PL/SQL scripting also it is possible.
    tables
    declare
    cursor cursor1 is select table_name from dba_tables where tablespace_name in ('USERDATA1');
    begin
    for cur1_rec in cursor1 loop
         execute immediate 'alter table '||cur1_rec.table_name||' move tablespace userdata2';
    end loop;
    end;
    indexes
    declare
    cursor cursor1 is select index_name from dba_indexes where tablespace_name in ('USERDATA1');
    begin
    for cur1_rec in cursor1 loop
    begin
         execute immediate 'alter index '||cur1_rec.index_name||' rebuild tablespace userdata2';
    exception
    when others then
    null;
    end;
    end loop;
    end;
    /

  • Move schema to anothe tablespace

    Hi
    During installation of one Oracle application , this has created "WIRELESS" schema in system tablespace. "WIRELESS" schema consis of table/index/LOB Objects. Now I want to migrate entire wireless schema to xx_tablespace. kindly suggest me the ways to do this.
    Thanks
    Krishna

    Have you read the documentation? Every single option for expdp and impdp is documented http://docs.oracle.com/cd/E11882_01/server.112/e22490/toc.htm
    As Osama suggested:
    a). Create a new schema with the default tablespace set to the tablespace to where you want to move the objects
    b). expdp the old schema
    c). impdp the using fromuser/touser to put the objects into the new schema
    d). Drop the old schema
    e). Rename the new schema to the old schema
    Another alternative that wouldn't need expdp/impdp and a temporary new schema would be to use alter table move and alter index rebuild to move the tables/indexes directly. If you have partitioned tables, you'd need to account for that. You can do the same in online mode using DBMS_REDEFINITION
    Which option you pick probably depends on a few things:
    a). Downtime requirements - DBMS_REDEFNITION can possibly do the reorg with zero downtime.
    b). Size of objects in the schema and whether you have enough space for the extra expdp file
    John

  • Move schema to another tablespace

    I want to move one schema and all objects own by particular schema to it's own tablespace (new_tablespace).
    will command provided below move all existing schema objects to new tablespace or just new objects?
    alter user default tablespace new_tablespace;

    mishomor wrote:
    I know it's long time since I posted this but I finally had a change to implement it.
    Thing is, if I execute command on one-by-one basis it works fine, but if I try block you guys posted it doesn't work. It ends with error:
    Error starting at line 1 in command:
    begin
    for tbl in (select table_name from all_tables where owner = 'FLOWS_020000') loop
    execute immediate 'alter table ' || tbl.table_name || ' move tablespace flows';are you executing this as the owner of 'tbl_name'?
    end loop;
    end;
    Error report:
    ORA-00942: table or view does not exist
    ORA-06512: at line 3
    00942. 00000 - "table or view does not exist"
    Cause:
    Action:
    begin
    for tbl in (select table_name from all_tables where owner = 'FLOWS_020000') loop
    execute immediate 'alter table ' || tbl.table_name || ' move tablespace flows';
    end loop;
    end;
    output of
    select table_name from all_tables where owner = 'FLOWS_020000';
    brings bunch of tables!!
    If I just run ...
    alter table FLOWS_020000.whatever_table move tablespace flows;
    alter index FLOWS_020000.whatever_index rebuild tablespace flows;
    ... it works fine.
    Because here you specifically qualified the table name with the owner. In your procedure above, you did not do that, so 'whatever_table' was assumed to be owned by whoever was executing the procedure.
    I am using SqlDeveloper 1.5.4

  • How to move Mail to another drive

    Hi all,
    mid 2011 MacMini, OS 10.8.5, 16GB RAM
    My applications and OS are on an SSD, and I have another internal drive for documents/data.
    Because speed is not an issue with mail, I would like to move the Mail folder onto another drive.
    I have moved the Mail folder from Users/<me>/Library to the other drive, made an Alias and moved the Alias into place on the SSD.
    When I try to run Mail, I get an error message, stating that I do not have access priveleges on the other drive. I have checked the access priveleges, insured that all are "Everybody: read and write" but still get the error message.
    Thanks

    Thanks Eric, but that alone didn't seem to work.
    I also tried changing the access on the source folder before making the alias, but it didn't make a difference.
    Using SymLink, I have got it to work, but only after several false starts. Just going folder to folder, SymLink would crash, but eventually I could get it to work by creating a folder in a folder, then dragging the link one level higher to the User/<me>/Library folder
    Anyway, got there in the end after struggling with it for a day.
    cheers, and thanks!

  • How to move actions to another computer?

    Hi,
    this is driving me nuts now. Can't seem to figure it out. I am in the process of moving all my stuff onto a new computer.
    Running CS3 on OS X.
    I have an action that I really want to move over to my new computer, but cannot figure out how to do this.
    help!

    Make sure the Action is in a Set. Then Save it to some place (any place will do, the Photoshop Actions folder in Presets is a good place.) and you can do whatever you want with the .atn file.
    This can all be done either from the flyout arrow menu in the Actions palette or with the Presets Manager.

Maybe you are looking for

  • Customer exit for changing order quantiy and scrap quantiy in MD11?

    Hi gurus, My objective is to update the order quantity and scrap quantiy field as per some logic and overwrite the existing values in MD11 (create planned order). Can you suggest the correct exit for incorporating these changes Thanks

  • How to set authenticationQuestion from a async form

    Hi, I need to set the authenticationQuestion and answers for new users coming from a db table. Do you have an idea of the data structure to use? Thanks a lot in advance.

  • Creative Zen Xtra 3

    Hello, i'm thinking about buying this mp3 player, but i have read a lot of reviews and some make my kinda worried.. : is it true that the headphone jack gets broken easily? 2: is this player detected automatically by windows xp or can it only be used

  • Bug in ABP based segregation at distribution group level

    We have Exchange 2013 based hosted exchange platform, tenants are segregated via ABP with custom attribute1 as a filter. users, distribution groups etc. are properly segregated as expected. when a user login to owa\ecp and navigate to Options->Groups

  • Date stamp in cell?

    New to Numbers. Is there a way to have the current date automatically inserted into a cell?