Change business tablespace and index tablespace methods

The tablespace where the modified table is located is as follows:

A. Single modification:

alter table TABLE_NAME (table name) move tablespace TABLESPACENAME (other table space name) 

B. Batch modification

①Query all tables under the current user 

select 'alter table '|| table_name ||' move tablespace tablespacename;' from user_all_tables; 

②Generate script - execute all the queried statements

C. Supplement:

select 'alter table '|| table_name ||' move tablespace SMS_WORK;' from user_all_tables  where  tablespace_name !='SMS_WORK';

 

The tablespace where the index is modified is as follows:

A. Oracle moves ordinary indexes to other tablespace syntax: (single modification)

       alter index index name rebuild tablespace other tablespace;

例:alter index ID rebuild tablespace GP_INDEX;

B. Use the script to execute the results of the query, so that it can be processed in batches

      ①Query all indexes under the current user:

select 'alter index '|| index_name ||' rebuild tablespace GP_INDEX(index tablespace);' from user_indexes;

      ②Generate script - execute all the queried statements

Notice:

If the data type of the column where the index is located is lob, the index cannot be migrated, and an error will be reported during migration: Cannot create an index with an expression of data type LOB

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324939474&siteId=291194637