oracle索引文件迁移步骤:
准备工作:
1)备份gbos用户表索引:通过plsqldevelop工具将gbos用户表索引全部导出,以做备份。
1.查看索引表空间 具有那些数据文件
select file_id,file_name,tablespace_name,bytes/1024/1024 m,blocks from dba_data_files
where tablespace_name='userindex'order by 1;
file_id file_name tablespace m blocks
--------- -------------------------------------------------- ---------- ---------- ----------
19 d:\oracle\oradata\innetdb\userindex01.dbf userindex 10240 1310720
20 d:\oracle\oradata\innetdb\userindex02.dbf userindex 10240 1310720
21 d:\oracle\oradata\innetdb\userindex03.dbf userindex 10240 1310720
22 d:\oracle\oradata\innetdb\userindex04.dbf userindex 10240 1310720
23 d:\oracle\oradata\innetdb\userindex05.dbf userindex 10240 1310720
39 d:\oracle\oradata\innetdb\userindex06.dbf userindex 6500 832000
40 d:\oracle\oradata\innetdb\userindex07.dbf userindex 6500 832000
41 d:\oracle\oradata\innetdb\userindex08.dbf userindex 6500 832000
42 d:\oracle\oradata\innetdb\userindex09.dbf userindex 6300 806400
43 d:\oracle\oradata\innetdb\userindex10.dbf userindex 6300 806400
62 d:\oracle\oradata\innetdb\userindex11.dbf userindex 1400 179200
63 d:\oracle\oradata\innetdb\userindex12.dbf userindex 1400 179200
2.创建新的索引表空间,,添加索引数据文件
create smallfile tablespace indextbs datafile 'd:\oracle\oradata\innetdb\indextbs\index001.dbf'
size 100m autoextend on next 100m maxsize 2000m logging extent management local segment space management auto;
alter tablespace indextbs add datafile 'd:\oracle\oradata\innetdb\indextbs\index003.dbf'
size 100m autoextend on next 100m maxsize 4000m ;
3.查找属于gbos用户的表索引,(除去clob类型的索引,clob索引存放在user表空间)
(分区索引存放在dba_segments表里,普通索引信息放在dba_indexes表里)
select 'alter index gbos.'||index_name||' rebuild tablespace indextbs'
from dba_indexes t where t.table_owner='gbos'
and index_name not like '%sys_%'
and t.tablespace_name='userindex'
select 'alter index gbos.'||index_name||' rebuild tablespace indextbs'
from dba_indexes t where t.tablespace_name='userindex' and t.table_owner='gbos'
普通索引迁移
alter index gbos.index_t_b_fault_list_status rebuild tablespace indextbs;
alter index gbos.index_t_b_fault_l_occur_time rebuild tablespace indextbs;
alter index gbos.index_t_b_fault_l_terminalid rebuild tablespace indextbs;
alter index gbos.idx_car_info_col rebuild tablespace indextbs;
alter index gbos.ix_t_o_open_door_rec_clct_date rebuild tablespace indextbs;
alter index gbos.ix_t_o_open_door_rec_term_id rebuild tablespace indextbs;
alter index gbos.ix_t_o_open_door_rec_tick rebuild tablespace indextbs;
分区索引迁移
alter index gbos.idx_o_period_info_cols rebuild partition sys_p61 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p62 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p63 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p64 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p65 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p66 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p67 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p68 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p69 tablespace indextbs;
alter index gbos.idx_o_period_info_cols rebuild partition sys_p70 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p41 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p42 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p43 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p44 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p45 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p46 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p47 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p48 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p49 tablespace indextbs;
alter index gbos.index_t_o_period_info rebuild partition sys_p50 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p51 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p52 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p53 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p54 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p55 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p56 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p57 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p58 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p59 tablespace indextbs;
alter index gbos.ix_t_o_period_info_tick rebuild partition sys_p60 tablespace indextbs;
