删除具有全局索引的分区表?
dropping partitioned tables with global indexes?
PROCEDURE purge_partitions
(
p_owner IN VARCHAR2
,p_name IN VARCHAR2
,p_retention_period IN NUMBER
) IS
BEGIN
FOR partition_rec IN (SELECT partition_name
,high_value
FROM dba_tab_partitions
WHERE table_owner = p_owner
AND table_name = p_name)
LOOP
IF SYSDATE >= add_months(to_date(substr(partition_rec.high_value
,12
,19)
,'YYYY-MM-DD HH24:MI:SS')
,p_retention_period)
THEN
execute_immediate('ALTER TABLE ' || p_owner || '.' ||
p_name || ' DROP PARTITION ' ||
partition_rec.partition_name)
END IF;
END LOOP;
END purge_partitions;
Purge_Partitions 过程处理删除分区基于
在单独的配置 Table 中提到的特定保留周期。我是
现在正在尝试增强此功能,它将负责
重建这些分区表的全局索引。不确定如何解决这个问题,非常感谢任何帮助。
考虑 update_index_clauses
,它使索引有效。
查看全局索引的文档和注意事项here
在你的情况下它将是:
alter table ttttt drop partition pppppp update global indexes;
或者让索引在 DROP PARTITION
中失效并用 alter index xxx rebuild
重建它们。您可以从此查询中获取要重建的索引列表
select OWNER, INDEX_NAME
from all_indexes
where owner = 'ooo' and table_name = 'tttttt' and status = 'UNUSABLE';
PROCEDURE purge_partitions
(
p_owner IN VARCHAR2
,p_name IN VARCHAR2
,p_retention_period IN NUMBER
) IS
BEGIN
FOR partition_rec IN (SELECT partition_name
,high_value
FROM dba_tab_partitions
WHERE table_owner = p_owner
AND table_name = p_name)
LOOP
IF SYSDATE >= add_months(to_date(substr(partition_rec.high_value
,12
,19)
,'YYYY-MM-DD HH24:MI:SS')
,p_retention_period)
THEN
execute_immediate('ALTER TABLE ' || p_owner || '.' ||
p_name || ' DROP PARTITION ' ||
partition_rec.partition_name)
END IF;
END LOOP;
END purge_partitions;
Purge_Partitions 过程处理删除分区基于 在单独的配置 Table 中提到的特定保留周期。我是 现在正在尝试增强此功能,它将负责 重建这些分区表的全局索引。不确定如何解决这个问题,非常感谢任何帮助。
考虑 update_index_clauses
,它使索引有效。
查看全局索引的文档和注意事项here
在你的情况下它将是:
alter table ttttt drop partition pppppp update global indexes;
或者让索引在 DROP PARTITION
中失效并用 alter index xxx rebuild
重建它们。您可以从此查询中获取要重建的索引列表
select OWNER, INDEX_NAME
from all_indexes
where owner = 'ooo' and table_name = 'tttttt' and status = 'UNUSABLE';