标签:
最近系统空间不够,要进行数据库清理,truncate数据之后,发现数据不连续,导致这个表空间占用巨大,想过使用shrink、move。但是shrink得效率比较慢,选择了move。语句大概如此:
SELECT ‘alter table sdmp.‘ || C.TABLE_NAME || ‘ move partition ‘ || C.PARTITION_NAME || ‘ tablespace sdmp_s update indexes;‘ FROM all_tab_statistics C INNER JOIN all_tab_partitions s ON s.partition_name=c.PARTITION_NAME AND s.tablespace_name=‘SDMP_S_201502‘ WHERE C.OWNER = ‘SDMP‘ AND C.OBJECT_TYPE <> ‘INDEX‘ ;
发现有些索引没有跟着移动目的(主要都是分区索引):使用select 找出对应语句并移动
SELECT ‘alter index sdmp.‘ || A.SEGMENT_NAME ||‘ rebuild partition ‘|| A.PARTITION_NAME ||‘ tablespace SDMP_S ;‘ FROM DBA_SEGMENTS A LEFT JOIN DBA_INDEXES B ON A.SEGMENT_NAME = B.INDEX_NAME WHERE A.TABLESPACE_NAME = ‘SDMP_S_201302‘;
删除表空间
drop tablespacee SDMP_S_201302 including contents and datafiles;
标签:
原文地址:http://www.cnblogs.com/2005wind/p/4958234.html