在範圍分割槽表上分割槽維護操作對全域性及本地索引狀態的影響(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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle分割槽表基礎運維-02範圍分割槽Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(1範圍分割槽)Oracle運維
- 範圍分割槽
- Oracle分割槽表基礎運維-06分割槽表索引Oracle運維索引
- Oracle分割槽表基礎運維-07增加分割槽(2 HASH分割槽)Oracle運維
- 檢視分割槽範圍
- 移動分割槽表和分割槽索引的表空間索引
- PG的非分割槽表線上轉分割槽表
- 記一次Oracle分割槽表全域性索引重建的過程Oracle索引
- Oracle分割槽表基礎運維-07增加分割槽(3列表分割槽)Oracle運維
- Oracle分割槽表基礎運維-04列表分割槽Oracle運維
- oracle分割槽表和分割槽表exchangeOracle
- Hive的靜態分割槽與動態分割槽Hive
- 增加表分割槽時,為local分割槽索引指定不同表空間的方法索引
- SSD固態硬碟要分割槽嗎?SSD固態硬碟分割槽與不分割槽的效能對比硬碟
- Oracle分割槽表基礎運維-09刪除分割槽Oracle運維
- Oracle分割槽表基礎運維-05組合分割槽Oracle運維
- Oracle分割槽表基礎運維-03HASH分割槽Oracle運維
- Spark操作Hive分割槽表SparkHive
- oracle分割槽表和非分割槽表exchangeOracle
- [oracle] expdp 匯出分割槽表的分割槽Oracle
- MySql資料分割槽操作之新增分割槽操作MySql
- PostgreSQL/LightDB 分割槽表之分割槽裁剪SQL
- 事務、全域性索引、透明分散式,再見,分割槽健!索引分散式
- Oracle分割槽表基礎運維-01分割槽表分類Oracle運維
- index_oracle索引梳理系列及分割槽表梳理IndexOracle索引
- 在分割槽表上使用正確的索引來提高效能索引
- oracle 分割槽表move和包含分割槽表的lob moveOracle
- 非分割槽錶轉換成分割槽表
- oracle 線上重新定義,普通表改變分割槽表,分割槽表可以更改型別、分割槽欄位等Oracle型別
- 對oracle分割槽表的理解整理Oracle
- 【MYSQL】 分割槽表MySql
- Hive中靜態分割槽和動態分割槽總結Hive
- Linux 新增LVM分割槽及LVM分割槽擴容LinuxLVM
- Oracle分割槽表基礎運維-07增加分割槽(4 RANGE_HASH)Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(5RANGE_LIST)Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(6RANGE_RANGE)Oracle運維
- HGDB的分割槽表實現SQL Server的分割槽檢視SQLServer
- 【Linux】MBR磁碟分割槽表只能有四個分割槽?Linux