在範圍分割槽表上分割槽維護操作對全域性及本地索引狀態的影響(2)
5,SPLIT PARTITION
5.1分割槽內無資料(從未插入)
alter table test
split partition p8 at (750) into (partition p81,partition p82);
select index_name,index_type,table_name,status,partitioned from user_indexes;
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P9 5 USABLE
IDX_TEST_ID P81 3 USABLE
IDX_TEST_ID P82 4 USABLE
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P9 5 USABLE
IDX_TEST_ID P81 3 USABLE
IDX_TEST_ID P82 4 USABLE
5.2分割槽內無資料(插入後刪除)
insert into test values(720,'x');
insert into test values(730,'x');
commit;
insert into test values(720,'x');
insert into test values(730,'x');
commit;
select * from test partition(p81);
ID X
---------- ------------------------------
720 x
730 x
ID X
---------- ------------------------------
720 x
730 x
delete from test where id in (720,730);
commit;
commit;
alter table test
split partition p81 at (725) into (partition p81a,partition p81b);
select index_name,index_type,table_name,status,partitioned from user_indexes;
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P9 6 USABLE
IDX_TEST_ID P82 5 USABLE
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P9 6 USABLE
IDX_TEST_ID P82 5 USABLE
5.3分割槽內有資料-需要移動資料
5.3.1 split partition
insert into test values(770,'x');
insert into test values(780,'x');
commit;
5.3.1 split partition
insert into test values(770,'x');
insert into test values(780,'x');
commit;
select * from test partition(p82);
ID X
---------- ------------------------------
770 x
780 x
ID X
---------- ------------------------------
770 x
780 x
alter table test
split partition p82 at (775) into (partition p82a,partition p82b);
split partition p82 at (775) into (partition p82a,partition p82b);
select * from test partition(p82a);
ID X
---------- ------------------------------
770 x
ID X
---------- ------------------------------
770 x
select * from test partition(p82b);
ID X
---------- ------------------------------
780 x
ID X
---------- ------------------------------
780 x
select index_name,index_type,table_name,status,partitioned from user_indexes;
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST UNUSABLE NO
IDX_TEST_ID NORMAL TEST N/A YES
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST UNUSABLE NO
IDX_TEST_ID NORMAL TEST N/A YES
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P82A 5 UNUSABLE
IDX_TEST_ID P82B 6 UNUSABLE
IDX_TEST_ID P9 7 USABLE
==>所涉及本地索引和全域性索引UNUSABLE
alter index idx_test_x rebuild;
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
alter index idx_test_id rebuild partition p82a;
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P82B 6 UNUSABLE
IDX_TEST_ID P9 7 USABLE
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P82B 6 UNUSABLE
IDX_TEST_ID P9 7 USABLE
alter index idx_test_id rebuild;
SQL> alter index idx_test_id rebuild;
alter index idx_test_id rebuild
*
ERROR at line 1:
ORA-14086: a partitioned index may not be rebuilt as a whole
alter index idx_test_id rebuild partition p82b;
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P82B 6 USABLE
IDX_TEST_ID P9 7 USABLE
5.3.2 split partition update indexes
insert into test values(760,'x');
commit;
commit;
select * from test partition(p82a);
ID X
---------- ------------------------------
770 x
760 x
ID X
---------- ------------------------------
770 x
760 x
alter table test
split partition p82a at (765) into (partition p82a1,partition p82a2) update indexes;
split partition p82a at (765) into (partition p82a1,partition p82a2) update indexes;
select * from test partition(p82a1);
ID X
---------- ------------------------------
760 x
ID X
---------- ------------------------------
760 x
select * from test partition(p82a2);
ID X
---------- ------------------------------
770 x
ID X
---------- ------------------------------
770 x
select index_name,index_type,table_name,status,partitioned from user_indexes;
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P9 8 USABLE
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P9 8 USABLE
==>本地和全域性索引都有效
5.3.3 split partition update global indexes
insert into test values(755,'x');
commit;
insert into test values(755,'x');
commit;
select * from test partition(p82a1);
ID X
---------- ------------------------------
760 x
755 x
ID X
---------- ------------------------------
760 x
755 x
alter table test
split partition p82a1 at (762) into (partition p82a1a,partition p82a1b) update global indexes;
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00001: unique constraint (SYS.I_INDPART_BOPART$) violated
split partition p82a1 at (762) into (partition p82a1a,partition p82a1b) update global indexes;
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00001: unique constraint (SYS.I_INDPART_BOPART$) violated
附:split partition遭遇bug OS:redhat as 4
參考:
另外thomas zhang對該情況由一個比較詳細的分析:http://space.itpub.net/785478/viewspace-571007
參考:
另外thomas zhang對該情況由一個比較詳細的分析:http://space.itpub.net/785478/viewspace-571007
==〉同一環境下,執行了5次不出問題的操作,也不保證下一次不出問題!!!
---換個地方再分割槽:)
alter table test
add partition p10 values less than(1000);
alter table test
add partition p10 values less than(1000);
insert into test values(820,'x');
insert into test values(860,'x');
commit;
insert into test values(860,'x');
commit;
select * from test partition(p9);
ID X
---------- ------------------------------
820 x
860 x
ID X
---------- ------------------------------
820 x
860 x
select index_name,index_type,table_name,status,partitioned from user_indexes;
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P10 9 USABLE
IDX_TEST_ID P9 8 USABLE
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P10 9 USABLE
IDX_TEST_ID P9 8 USABLE
9 rows selected.
alter table test
split partition p9 at (850) into (partition p91,partition p92) update global indexes;
split partition p9 at (850) into (partition p91,partition p92) update global indexes;
select * from test partition(p91);
ID X
---------- ------------------------------
820 x
ID X
---------- ------------------------------
820 x
select * from test partition(p92);
ID X
---------- ------------------------------
860 x
ID X
---------- ------------------------------
860 x
SQL> select index_name,index_type,table_name,status,partitioned from user_indexes;
INDEX_NAME INDEX_TYPE TABLE_NAME STATUS PARTITIONE
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
------------------------------ --------------- ------------------------------ -------------------- ----------
IDX_TEST_X NORMAL TEST VALID NO
IDX_TEST_ID NORMAL TEST N/A YES
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P10 10 USABLE
IDX_TEST_ID P91 8 UNUSABLE
IDX_TEST_ID P92 9 UNUSABLE
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P10 10 USABLE
IDX_TEST_ID P91 8 UNUSABLE
IDX_TEST_ID P92 9 UNUSABLE
10 rows selected.
==〉本地索引狀態為UNUSABLE
alter index idx_test_id rebuild partition p91;
alter index idx_test_id rebuild partition p92;
alter index idx_test_id rebuild partition p92;
select index_name,partition_name,partition_position,status from user_ind_partitions;
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P92 9 USABLE
IDX_TEST_ID P10 10 USABLE
IDX_TEST_ID P91 8 USABLE
INDEX_NAME PARTITION_NAME PARTITION_POSITION STATUS
------------------------------ --------------- ------------------ --------------------
IDX_TEST_ID P81A 3 USABLE
IDX_TEST_ID P82B 7 USABLE
IDX_TEST_ID P7 2 USABLE
IDX_TEST_ID P82A2 6 USABLE
IDX_TEST_ID P82A1 5 USABLE
IDX_TEST_ID P1 1 USABLE
IDX_TEST_ID P81B 4 USABLE
IDX_TEST_ID P92 9 USABLE
IDX_TEST_ID P10 10 USABLE
IDX_TEST_ID P91 8 USABLE
10 rows selected.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18922393/viewspace-755144/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 在範圍分割槽表上分割槽維護操作對索引狀態的影響索引
- 在範圍分割槽表上分割槽維護操作對索引狀態的影響(1)索引
- oracle本地分割槽索引跨分割槽對成本的影響Oracle索引
- 分割槽表的不同操作對索引的影響索引
- 操作分割槽表對global和local索引的影響索引
- 分割槽表、分割槽索引和全域性索引部分總結索引
- 分割槽表全域性索引與本地索引的選擇索引
- 分割槽表本地索引與全域性索引的區別索引
- 分割槽表中全域性及本地分割槽索引什麼時候會失效及處理索引
- 範圍分割槽表和INTERVAL分割槽表對於SPLIT分割槽的區別
- 全域性分割槽索引和區域性分割槽索引索引
- 分割槽表 全域性索引與本地索引失效測試索引
- Oracle分割槽表基礎運維-02範圍分割槽Oracle運維
- 分割槽表中的區域性分割槽索引及全域性索引與執行計劃索引
- 分割槽表的分割槽資料刪除、truncate會對全域性和區域性索引產生什麼影響索引
- 全面學習分割槽表及分割槽索引(17)--其它索引分割槽管理操作索引
- Oracle分割槽表基礎運維-07增加分割槽(1範圍分割槽)Oracle運維
- 分割槽表中全域性及本地分割槽索引什麼時候會失效及處理[final]索引
- Oracle分割槽表及分割槽索引Oracle索引
- Oracle分割槽表全域性索引新增分割槽時不會失效Oracle索引
- 分割槽表及分割槽索引建立示例索引
- oracle分割槽表的常規操作導致對索引的影響Oracle索引
- 有關Oracle表分割槽進行(DML)維護後對索引的影響的分析Oracle索引
- 全面學習分割槽表及分割槽索引(15)--修改表分割槽屬性和模板索引
- 全面學習分割槽表及分割槽索引(13)--分隔表分割槽索引
- oracle分割槽及分割槽索引partition_partition index_維護(一)Oracle索引Index
- oracle分割槽及分割槽索引partition_partition index_維護(二)Oracle索引Index
- oracle分割槽及分割槽索引partition_partition index_維護(三)Oracle索引Index
- oracle分割槽及分割槽索引partition_partition index_維護(四)Oracle索引Index
- 全面學習分割槽表及分割槽索引(10)--交換分割槽索引
- [轉]Oracle分割槽索引--本地索引和全域性索引比較Oracle索引
- Oracle分割槽索引--本地索引和全域性索引比較(轉)Oracle索引
- 全面學習分割槽表及分割槽索引(9)--刪除表分割槽索引
- 全面學習分割槽表及分割槽索引(11)--合併表分割槽索引
- 全面學習分割槽表及分割槽索引(12)--修改list表分割槽索引
- ddl 導致分割槽表全域性索引unusable索引
- ORACLE 範圍分割槽 partition-range分割槽Oracle
- Oracle分割槽表基礎運維-06分割槽表索引Oracle運維索引