【實驗】【PARTITION】RANGE分割槽表移動表分割槽(Move Partition)

secooler發表於2009-07-16
1.移動分割槽表的作用大體有兩個
1)與move表一樣,可以降低行遷移
2)修改分割槽的表空間

2.需要注意的問題:
1)對於分割槽記憶體在大量資料的時候在移動的過程中會帶來大量的IO,這裡注意一下
2)注意索引是否失效的問題

3.建立一個簡單的分割槽表
sec@ora10g> create table t_partition_range (id number,name varchar2(50))
  2  partition by range(id)(
  3  partition t_range_p1   values less than (10)       tablespace tbs_part01,
  4  partition t_range_p2   values less than (maxvalue) tablespace tbs_part02);


Table created.

4.檢視當前的分割槽情況
sec@ora10g> col TABLE_NAME for a20
sec@ora10g> col partition_name for a20
sec@ora10g> col HIGH_VALUE for a10
sec@ora10g> col TABLESPACE_NAME for a15
sec@ora10g> select table_name,partition_name,high_value,tablespace_name from user_tab_partitions where table_name='T_PARTITION_RANGE' order by partition_position;

TABLE_NAME           PARTITION_NAME       HIGH_VALUE TABLESPACE_NAME
-------------------- -------------------- ---------- ---------------
T_PARTITION_RANGE    T_RANGE_P1           10         TBS_PART01
T_PARTITION_RANGE    T_RANGE_P2           MAXVALUE   TBS_PART02

5.演示普通的move,目的是減少行遷移
sec@ora10g> alter table T_PARTITION_RANGE move partition T_RANGE_P1 update indexes;

Table altered.

sec@ora10g> alter table T_PARTITION_RANGE move partition T_RANGE_P2 update indexes;

Table altered.

sec@ora10g> select table_name,partition_name,high_value,tablespace_name from user_tab_partitions where table_name='T_PARTITION_RANGE' order by partition_position;

TABLE_NAME           PARTITION_NAME       HIGH_VALUE TABLESPACE_NAME
-------------------- -------------------- ---------- ---------------
T_PARTITION_RANGE    T_RANGE_P1           10         TBS_PART01
T_PARTITION_RANGE    T_RANGE_P2           MAXVALUE   TBS_PART02

6.演示一下調整表空間的move語法
sec@ora10g> alter table T_PARTITION_RANGE move partition T_RANGE_P1 tablespace TBS_PART03 update indexes;

Table altered.

sec@ora10g> alter table T_PARTITION_RANGE move partition T_RANGE_P2 tablespace TBS_PART04 update indexes;

Table altered.

sec@ora10g> select table_name,partition_name,high_value,tablespace_name from user_tab_partitions where table_name='T_PARTITION_RANGE' order by partition_position;

TABLE_NAME           PARTITION_NAME       HIGH_VALUE TABLESPACE_NAME
-------------------- -------------------- ---------- ---------------
T_PARTITION_RANGE    T_RANGE_P1           10         TBS_PART03
T_PARTITION_RANGE    T_RANGE_P2           MAXVALUE   TBS_PART04

注意一下,這裡表空間已經發生了變化

-- The End --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-609347/,如需轉載,請註明出處,否則將追究法律責任。

相關文章