背景:
SEND_CONTROL_HIS1分区表存在大量无用数据,虽不影响性能,但可以删除部分分区节省存储空间。
--查表空间有哪些对象
select owner,segment_name,segment_type,partition_name,bytes/1024/1024 As "占据空间M"
from dba_segments a where a.tablespace_name='PORT_DATA' And segment_name='CONTROL_HIS1'
Order By bytes Desc
实施步骤:
1、删除该表上半年分区
详见附表2:TRACK_PART19以前的数据分区可删除
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART4;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART5;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART6;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART7;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART8;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART9;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART10;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART11;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART12;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART13;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART14;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART15;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART16;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART17;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART18;
ALTER TABLE SEND_CONTROL_HIS1 DROP PARTITION TRACK_PART19;
2、清空该表6月份分区
详见附表2:TRACK_PART24以前的数据分区可TRUNCATE
ALTER TABLE SEND_CONTROL_HIS1 TRUNCATE PARTITION TRACK_PART20;
ALTER TABLE SEND_CONTROL_HIS1 TRUNCATE PARTITION TRACK_PART21;
ALTER TABLE SEND_CONTROL_HIS1 TRUNCATE PARTITION TRACK_PART22;
ALTER TABLE SEND_CONTROL_HIS1 TRUNCATE PARTITION TRACK_PART23;
ALTER TABLE SEND_CONTROL_HIS1 TRUNCATE PARTITION TRACK_PART24;