1、查看一个表是不是分区表select table_name from dba_part_tables where owner = 'HS_HIS' and table_name='HIS_TRADEDAILYTOTAL';这里查询结果为空,代表该表不是分区表
2、创秃赈沙嚣建分区表(结构和非分区表相同)create table hs_his.t_his_tradedailytotalpartition by ran爿讥旌护ge(init_date)(partition PMAX values less than (maxvalue))as select * from hs_his.his_tradedailytotal where 1=2;
3、对原表进行备份包括索引也进行备份PL/SQL有个查看SQL的功能,
4、交换数据(数据从非分区表到分区表)alter table hs_his.t_his_tradedailytotal exchange partition pmax with table hs_his.his_tradedailytotal;
5、删除非分区表drop table his_tradedailytotal;
6、将分区表重命名为原非分区表名alter table t_his_tradedailytotal rename to his_tradedailytotal;
7、再次检查表是豸阏恢闲否为分区表select table_owner,table_name,partition_name from dba_tab_partitions a where a.table_owner='HS_HIS' and a.table_name='HIS_TRADEDAILYTOTAL';
8、对pmax进行split分区,(把所需分区从pmax split出来):ALTER TABLE HIS_TRADEDAILYTOTAL SPLIT PARTITION PMAX AT (20180800) INTO (partition P201801, partition PMAX) ;分区区间仅供参考
9、备份的索引进行重建,以及检查分区表是否正确