移动分区表的表空间
1) 非组合分区表
alter table RPT_F_STATION_DP move PARTITION
SYS_P3742 tablespace reportdata;
alter table RPT_F_STATION_DP move PARTITION
2) 组合分区表:
(1)先移动子分区到另一个表空间
alter table RPT_F_CABECF move SUBPARTITION SYS_SUBP8842 tablespace reportdata
(2)subpartition已经move走了,就剩下subpartition的father了,那就不需要move了,改一下分区的属性就可以了。
ALTER TABLE RPT_F_CABECF MODIFY DEFAULT ATTRIBUTES FOR PARTITION PARTITION_660 TABLESPACE reportdata;
ALTER TABLE RPT_F_CABECF MODIFY DEFAULT ATTRIBUTES FOR PARTITION PARTITION_660 TABLESPACE reportdata;
注:
如直接move含有子分区的分区将发生如下错误
如直接move含有子分区的分区将发生如下错误
ORA-14257:
cannot move partition other than a Range or Hash partition
移动分区表上 index 的表空间1)非分区indexALTER INDEX PK_RPT_F_NOFINISH_WORKSHEET REBUILD TABLESPACE REPORTDATA;2)无子分区的index ALTER INDEX IDX_RPT_F_STATION_DP_1REBUILD PARTITION SYS_P3721 TABLESPACE REPORTDATA;
3)子分区indexALTER INDEX IDX_RPT_F_CABECF_1 REBUILD SUBPARTITION SYS_SUBP8842 TABLESPACE REPORTDATA;自动生成需要的脚本 SELECT 'alter table|| table_name || ' move PARTITION ' || partition_name || ' tablespace reportdata;' FROM USER_TAB_PARTITIONS WHERE SUBPARTITION_COUNT = 0 AND tablespace_name = 'RMGZ';
-- 非组合分区表 'alter table'
|| table_name
|| ' move subPARTITION SUBPARTITION_NAME
|| ' tablespace reportdata; FROM USER_TAB_SUBPARTITIONS
WHERE SUBPARTITION_COUNT > 0 AND tablespace_name = 'RMGZ';
--移动子分区SELECT 'ALTER TABLE ' || table_name || ' MODIFYDEFAULT ATTRIBUTES FOR PARTITION ' || partition_name || ' TABLESPACE reportdata;FROM USER_TAB_PARTITIONSW WHERE SUBPARTITION_COUNT > 0 AND tablespace_name = 'RMGZ';
--修改母分区属性 SELECT 'ALTER INDEX ' || INDEX_NAME || ' REBUILD TABLESPACE REPORTDATA; FROM USER_INDEXES WHERE tablespace_name='RMGZ';
SELECT 'ALTER INDEX || || ' REBUILD PARTITION ' || PARTITION_NAME || ' TABLESPACE REPORTDATA; ' FROM USER_IND_PARTITIONS where SUBPARTITION_COUNT = 0 and tablespace_name='RMGZ'; -- 无子分区的index SELECT 'ALTER INDEX || || ' REBUILD SUBPARTITION ' || ' TABLESPACE REPORTDATA; FROM USER_IND_SUBPARTITIONSz where tablespace_name='RMGZ'; --子分区index