oracle - 删除具有全局索引的分区表?
问题描述
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 过程根据单独的配置表中提到的特定保留优先级处理删除分区。我现在正在尝试增强此功能,该功能将负责重建这些分区表的全局索引。不知道如何去做,任何帮助都非常感谢。
解决方案
考虑update_index_clauses
,它使索引保持有效。
在此处查看全局索引的文档和注意事项
在您的情况下,它将是:
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';
推荐阅读
- c# - FlaUI.Core.dll 中发生 System.ComponentModel.Win32Exception 类型的未处理异常
- grpc - Juniper OS (Junos) 上的遥测 (jtimon/Telegraf) 问题
- proxy - kotlinNpmInstall 在企业代理后面
- python - 从导入的模块中引用 __file__
- android - 致命信号 11 (SIGSEGV),代码 2,tid 5938 中的故障地址 0x74eaaba0
- r - 为面板回归转换数据框
- python - 重命名 pytest.mark.parametrize 中的参数
- angular - Angular Material Tree 向每个节点添加子按钮
- php - 如何在 Laravel 中调整图像大小并同时将数据保存在数据库中
- android - 访问 binding-Object 并遍历属性以访问我的所有自定义按钮