首页 > 数据库 >【Oracle】How Do Indexes Become Unusable

【Oracle】How Do Indexes Become Unusable

时间:2024-11-07 10:30:17浏览次数:3  
标签:operations Do PARTITION index partition Unusable Indexes ALTER partitions

遇到的场景:Oracle数据库的分区表出现UNUSABLE INDEX,下述文档用于解决相关问题。

Symptoms

Description of which operations mark index partitions as INDEX UNUSABLE.
描述那些操作使得索引不可用

Cause

There are six types of maintenance operations and adding a partition to a Hash-Partitioned Table that mark index partitions INDEX UNUSABLE (IU). In all cases, you must rebuild the index partitions when the operation is complete.

有六种类型操作使得索引不可用

Solution

Maintenance operations causing index partitions to become INDEX UNUSABLE (IU):

  1. IMPORT PARTITION or conventional path SQL*Loader.

  2. Direct-path SQL*Loader leaves affected local index partitions and global indexes in an IU state if it does not complete successfully.

  3. Partition maintenance operations like ALTER TABLE MOVE PARTITION.

  4. Partition maintenance operations like ALTER TABLE TRUNCATE PARTITION.

  5. Partition maintenance operations like ALTER TABLE SPLIT PARTITION.

  6. Index maintenance operations like ALTER INDEX SPLIT PARTITION.

  7. Adding a Partition to a Hash-Partitioned Table

一种是Direct-path 直插方式,另外一种是分区表添加分区。可能使得索引不可用。

Adding a Partition to a Hash-Partitioned Table

When you add a partition to a hash-partitioned table, the database populates the new partition with rows rehashed from an existing partition (selected by the database) as determined by the hash function. Consequently, if the table contains data, then it may take some time to add a hash partition.

The following statements show two ways of adding a hash partition to table <Table_Name>. Choosing the first statement adds a new hash partition whose partition name is system generated, and which is placed in the default tablespace. The second statement also adds a new hash partition, but that partition is explicitly named <Partition_Name> and is created in tablespace <Tablespace_Name>.

ALTER TABLE <Table_Name> ADD PARTITION;

ALTER TABLE <Table_Name> ADD PARTITION <Partition_Name> TABLESPACE <Tablespace_Name>;

Indexes may be marked UNUSABLE as explained in the following table:

Table Type Index Behavior
Regular (Heap) Unless you specify UPDATE INDEXES as part of the ALTER TABLE statement:The local indexes for the new partition, and for the existing partition from which rows were redistributed, are marked UNUSABLE and must be rebuilt.All global indexes, or all partitions of partitioned global indexes, are marked UNUSABLE and must be rebuilt.
Index-organized For local indexes, the behavior is identical to heap tables. All global indexes remain usable.

Each of these operations may cause index partitions to be marked IU which will require the index partitions to be rebuilt.

上述英文说明,为什么分区表可能出现索引不可用。

Version 10.2 and later

By default, many table maintenance operations on partitioned tables invalidate (mark UNUSABLE) the corresponding indexes or index partitions. You must then rebuild the entire index or, in the case of a global index, each of its partitions. The database lets you override this default behavior if you specify UPDATE INDEXES in your ALTER TABLE statement for the maintenance operation. Specifying this clause tells the database to update the index at the time it executes the maintenance operation DDL statement.

The following operations support the UPDATE INDEXES clause:

*  ADD PARTITION | SUBPARTITION
*  COALESCE PARTITION | SUBPARTITION
*  DROP PARTITION | SUBPARTITION
*  EXCHANGE PARTITION | SUBPARTITION
*  MERGE PARTITION | SUBPARTITION
*  MOVE PARTITION | SUBPARTITION
*  SPLIT PARTITION | SUBPARTITION
*  TRUNCATE PARTITION | SUBPARTITION

Conclusion

如果分区表的索引变成不可用,可以通过
1.重建索引
2.删除重复数据之后,再次重建索引

if Some Maintenance operations causing index partitions to become INDEX UNUSABLE (IU).we can use some methods as follows:

  1. recreate the constraint/index.
  2. if necessary,remove deplicate data and rebuild index.
ALTER INDEX index_name REBUILD;

how to remove deplicat data. you can visit https://blogs.oracle.com/sql/post/how-to-find-and-delete-duplicate-rows-with-sql.

标签:operations,Do,PARTITION,index,partition,Unusable,Indexes,ALTER,partitions
From: https://www.cnblogs.com/zhangshengdong/p/18531673

相关文章

  • Windows安装管理多个NodeJS版本
    下载nvm管理工具,下载完成解压安装https://github.com/coreybutler/nvm-windows/releases选择nvm安装位置选择nvm安装node版本的安装位置如果提示你已经安装的有nodejs,提示你是否通过nvm管理nodejs,选择是,继续安装即可Win+R打开cmd命令窗口nvm-v查看安装的nv......
  • 【日常记录】解包android vendor_boot.img和vendor_boot-debug.img
    查看文件类型:$filevendor_boot.imgvendor_boot.img:data$filevendor_boot-debug.imgvendor_boot-debug.img:dataunpack_bootimg用法:$./unpack_bootimg-husage:unpack_bootimg[-h]--boot_imgBOOT_IMG[--outOUT][--format{info,mkbootimg}][-0]Unpacks......
  • 6、显卡品牌分类介绍:七彩虹 - 计算机硬件品牌系列文章.docx
    七彩虹是一个知名的显卡品牌,‌以其高质量的产品和广泛的市场认可而闻名。‌自1995年在中国深圳市成立以来,‌七彩虹经历了从代理品牌产品到自主研发、‌自主生产、‌自主品牌、‌自主销售为一体的完整产业链企业的转变。‌这个转变过程跨越了三大战略转型阶段,‌体现了七彩虹在......
  • docker命令1
     dockerrun--privileged-d--restart=always--namexxx_video_service--net=host-v/docker/data/video/xxx:/mnt/data/xxx-v/docker/data/video/testVideo:/root/testVideo192.168.21.237:50000/xyxy-amd/xxx_video_service:V1.1.1.20100531_Alpha 有的宿主机......
  • GPU 环境搭建指南:如何在裸机、Docker、K8s 等环境中使用 GPU
    本文主要分享在不同环境,例如裸机、Docker和Kubernetes等环境中如何使用GPU。跳转阅读原文:GPU环境搭建指南:如何在裸机、Docker、K8s等环境中使用GPU1.概述仅以比较常见的NVIDIAGPU举例,系统为Linux,对于其他厂家的GPU设备理论上流程都是一样的。省流:对于裸......
  • POJ3481 Double Queue (map)
     使用map,并将优先级值放在first以自动排序,如果输入的代码为2,就输出最后一组元素的second并删去,输入代码为3时同理。#include<iostream>#include<map>#include<vector>usingnamespacestd;intmain(void){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);......
  • MarkDown语法
    MarkDown语法标题:一级标题二级标题三级标题四级标题,最多到六级标题加粗斜体加粗斜体废弃引用Maxwell分割线图片超链接http://www.baidu.com2024-11-0623:20:49列表ABC表格名字性别生日张三男1997-1-1代码select*fromdict_item;......
  • **BMP(Bitmap)**是一种图像文件格式,通常用于存储位图图像。它是最早期的图像格式之一,最
    **BMP(Bitmap)**是一种图像文件格式,通常用于存储位图图像。它是最早期的图像格式之一,最早由微软在Windows操作系统中引入。BMP格式的文件扩展名通常为.bmp,它用于表示由像素网格组成的图像,像素数据存储在文件中,通常没有压缩,因此能够保存原始的图像数据。1. BMP图片格式是什么?......
  • 遇到XINPUT1-3.dll未在Windows上指定运行?尝试这些解决方案
    当出现“XINPUT1-3.dll没有被指定在Windows上运行”这样的错误提示时,可能是由于以下几种原因导致的,下面是一些相应的解决方法:一、文件损坏或不兼容1.重新下载DLL文件从可靠的来源获取XINPUT1-3.dll文件。最好是从微软官方网站或者游戏官方网站寻找该文件。避......
  • windows下电脑自定义磁盘图标,u盘图标,文件夹图标
    闲言更改图标要确定有ico(icon)格式图片文件,文件比例1:1,一般像素大小比例推荐128:128确保文件后缀有显示目录闲言寻找或制作ico图片直接下载网络图片制作ico文件在线制作本地制作ico磁盘/U盘图标更改文件夹图标更改寻找或制作ico图片直接下载网络图片这里推荐阿里巴巴......