--创建测试表 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;
SQL> commit; --创建本地分区索引 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;
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 *
ADD (HASH) COALESCE (HASH) DROP EXCHANGE MERGE MOVE SPLIT TRUNCATE
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有