zoukankan      html  css  js  c++  java
  • rebuild 分区索引

    今天要做一个任务,rebuild 一个索引, 该索引建立在有11亿条数据的表上。

    对于非组合分区索引,需要rebuild 每个分区(partition),不能直接rebuild整个索引,

    对于组合分区索引,需要rebuild每个子分区(subpartition),不能直接rebuild整个索引,也不能直接rebuild 分区(partition)

    由于我要rebuild的索引很大,有100多个分区,928个子分区,因此利用手工写rebuild命令显然不合适(要写928个命令 哭。。。),下面整理一下脚本供以后利用。

    由于我这里是仓库环境,所以我没有写rebuild online.另外请注意,sunpartition 的索引 rebuild 的时候不能 设置 nologging, pctfree ...等storage条件。只能设置 tablespace ...parallel 否则 报错如下:

    ORA-14189: this physical attribute may not be specified for an index subpartition

    非组合分区索引

    SET ECHO OFF
    set termout off 
    set feedback off
    set heading off
    set linesize 200
    set pagesize 10000

    spool c:/partition.sql

    select 'alter index ' || index_owner || '.' ||index_name ||' rebuild partition ' || PARTITION_NAME || ' nologging parallel ;'
    from dba_ind_partitions where index_owner='&index_owner' and index_name=&index_name;

    spool off

    对于组合分区索引


    SET ECHO OFF
    set termout off 
    set feedback off
    set heading off
    set linesize 200
    set pagesize 10000

    spool c:/subpartition.sql
    select 'alter index ' || index_owner || '.' ||index_name ||' rebuild subpartition ' || subpartition_name || '  parallel ;'
    from dba_ind_subpartitions where index_owner='&index_owner' and index_name='&index_name';
    spool off

  • 相关阅读:
    Java学习笔记
    计算机基础知识点整理
    codeblock的GUN GCC compiler问题
    秋招小米面经
    闭包的特性(只做了粗略整理)
    overflow:hidden为什么可以清除浮动?
    项目中出现的问题
    MySql 备忘还原数据库
    MySql语句备忘 JSON截取
    MySql语句备忘 UPDATE
  • 原文地址:https://www.cnblogs.com/hehe520/p/6330589.html
Copyright © 2011-2022 走看看