oracle分区索引的失效和重建代码示例
网络编程 2021-07-05 16:09www.168986.cn编程入门
这篇文章主要介绍了oracle分区的失效和重建代码示例,长沙网络推广觉得挺不错的,这里分享给大家,供需要的朋友参考。
上一篇文章中我们了解了的相关内容,接下来的这篇文章,我们将探讨oracle分区索引的失效和重建问题,提供了相关代码示例供大家参考,具体如下。
--创建测试表 SQL> create table t as select object_id,object_name from dba_objects;
表已创建。
SQL> select min(object_id),max(object_id) from t; MIN(OBJECT_ID) MAX(OBJECT_ID) -------------- -------------- 2 76083 SQL> create table t_part(object_id int,object_name varchar2(1000)) partition by range(object_id) 2 ( 3 partition p1 values less than (10000), 4 partition p2 values less than (20000), 5 partition p3 values less than (30000), 6 partition p4 values less than (40000), 7 partition pm values less than (maxvalue));
表已创建。
SQL> insert into t_part select * from t;
已创建72663行。
SQL> mit; --创建本地分区索引 SQL> create index idx_part_local on t_part(object_name) local;
索引已创建。
创建全局非分区索引
SQL> create index idx_part_global on t_part(object_id) global;
索引已创建。
删除其中一个分区
SQL> alter table t_part drop partition p1;
表已更改。
全局非分区索引失效,本地分区索引没有失效
SQL> select status,index_name from user_indexes s where index_name='IDX_PART_GLOBAL'; STATUS INDEX_NAME -------- ------------------------------ UNUSABLE IDX_PART_GLOBAL SQL> select status,index_name from user_ind_partitions s where index_name='IDX_PART_LOCAL'; STATUS INDEX_NAME -------- ------------------------------ USABLE IDX_PART_LOCAL USABLE IDX_PART_LOCAL USABLE IDX_PART_LOCAL USABLE IDX_PART_LOCAL --重建失效索引 SQL> alter index idx_part_global rebuild;
索引已更改。
在删除表分区的时候,可以通过以下命令进行索引重建
alter table t_part drop partition p2 update indexes;
创建全局分区索引
SQL> drop index idx_part_global;
索引已删除。
SQL> CREATE INDEX idx_part_global_full ON t_part (object_id) 2 GLOBAL PARTITION BY RANGE (object_id) 3 (PARTITION p1 VALUES LESS THAN (10000), 4 PARTITION p2 VALUES LESS THAN (30000), 5 PARTITION p3 VALUES LESS THAN (MAXVALUE));
索引已创建。
--删除其中一个分区 SQL> alter table t_part drop partition p3;
表已更改。
--全局分区索引失效 SQL> select status,index_name from user_ind_partitions s where index_name='IDX_PART_GLOBAL_FULL'; STATUS INDEX_NAME -------- ------------------------------ UNUSABLE IDX_PART_GLOBAL_FULL UNUSABLE IDX_PART_GLOBAL_FULL UNUSABLE IDX_PART_GLOBAL_FULL SQL> select /*+index(t IDX_PART_LOCAL)*/ * from t_part t where object_name = '/7f6c264c_IIOPAddress'; OBJECT_ID OBJECT_NAME ---------- ----------------------------------- 35031 /7f6c264c_IIOPAddress 35030 /7f6c264c_IIOPAddress SQL> select /*+index(t IDX_PART_GLOBAL_FULL)*/ * from t_part t where object_id > 35000;
select /*+index(t IDX_PART_GLOBAL_FULL)*/ * from t_part t where object_id > 35000
*
第 1 行出现错误:
ORA-01502: 索引 'SCOTT.IDX_PART_GLOBAL_FULL' 或这类索引的分区处于不可用状态
当需要对分区表进行狼蚁网站SEO优化操作时,都会导致全局索引的失效。
ADD (HASH) COALESCE (HASH) DROP EXCHANGE MERGE MOVE SPLIT TRUNCATE
之后需要对失效索引进行重建,也可以在删除分区表的时候指定 UPDATE INDEXES 直接进行索引的重建。
总结
以上就是本文关于oracle分区索引的失效和重建代码示例的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:、等,有什么问题可以直接留言,长沙网络推广会及时回复大家的。感谢朋友们对本站的支持!
上一篇:oracle常见故障类别及规划解析
下一篇:oracle普通表转化为分区表的方法
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程