ORACLE 11g 範圍分割槽錶轉換INTERVAL分割槽表
ORACLE 11g 範圍分割槽錶轉換INTERVAL分割槽表
INTERVAL分割槽其實是一種比較特殊的範圍分割槽,因此可以很方便的將RANGE分割槽錶轉化為INTERVAL分割槽表,同樣可以將INTERVAL分割槽錶轉化為RANGE分割槽表。
對於一個普通的時間範圍分割槽表:
5. 加大範圍,插入資料
6. 檢視分割槽資料分部情況
exec dbms_stats.gather_table_stats('','T_PART3');
若分割槽表存在maxvalue分割槽,則不能直接轉換為INTERVAL分割槽,需要先將maxvalue分割槽刪除才可轉換。
ERROR at line 1:
ORA-14759: SET INTERVAL is not legal on this table.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Message:
ORA-14759: SET INTERVAL is not legal on this table.
Cause:
ALTER TABLE SET INTERVAL is only legal on a range partitioned table with a single partitioning column. Additionally this table cannot have a maxvalue partition.
Action:
Use SET INTERVAL only on a valid table
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INTERVAL分割槽其實是一種比較特殊的範圍分割槽,因此可以很方便的將RANGE分割槽錶轉化為INTERVAL分割槽表,同樣可以將INTERVAL分割槽錶轉化為RANGE分割槽表。
對於一個普通的時間範圍分割槽表:
- 1. 建立分割槽表
-
CREATE TABLE T_PART3(ID NUMBER,NAME VARCHAR2(30),CREATE_DATE TIMESTAMP)
-
PARTITION BY RANGE (CREATE_DATE)
-
(PARTITION P3_1 VALUES LESS THAN (TIMESTAMP' 2016-01-01 00:00:00') ,
-
PARTITION P3_2 VALUES LESS THAN (TIMESTAMP' 2016-02-01 00:00:00') ,
-
PARTITION P3_3 VALUES LESS THAN (TIMESTAMP' 2016-03-01 00:00:00')
-
);
-
2. 隨機插入資料
-
insert into T_PART3
- select rownum*10,'N'||level,sysdate+dbms_random.value(0,250) from dual connect by level <1000;
--超出分割槽範圍
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
--修改語句,繼續插入
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
--修改語句,繼續插入
- insert into T_PART3
-
select rownum*10,'N'||level,sysdate+dbms_random.value(0,50) from dual connect by level <1000;
-
commit;
-
-
exec dbms_stats.gather_table_stats('','T_PART3');
-
-
PL/SQL procedure successfully completed.
-
- 3. 檢視分割槽資料分部情況
-
select table_owner,table_name,partition_name,partition_position,interval,num_rows, HIGH_VALUE from dba_tab_partitions where table_name = 'T_PART3';
-
-
TABLE_OWNER TABLE_NAME PARTITION_NAME PARTITION_POSITION INTERV NUM_ROWS HIGH_VALUE
-------------------- -------------------------------- -------------------- ------------------ ------ ---------- -----------------------------------
IBM T_PART3 P3_1 1 NO 0 TIMESTAMP' 2016-01-01 00:00:00'
IBM T_PART3 P3_2 2 NO 452 TIMESTAMP' 2016-02-01 00:00:00'
IBM T_PART3 P3_3 3 NO 547 TIMESTAMP' 2016-03-01 00:00:00'
- 4. 轉換為按月的INTERVAL分割槽表
- ALTER TABLE T_PART3 SET INTERVAL (NUMTOYMINTERVAL (1,'MONTH'));
5. 加大範圍,插入資料
- insert into T_PART3
- select rownum*10,'N'||level,sysdate+dbms_random.value(0,250) from dual connect by level <2000;
6. 檢視分割槽資料分部情況
exec dbms_stats.gather_table_stats('','T_PART3');
-
select table_owner,table_name,partition_name,partition_position,interval,num_rows, HIGH_VALUE from dba_tab_partitions where table_name = 'T_PART3';
-
-
TABLE_OWNER TABLE_NAME PARTITION_NAME PARTITION_POSITION INTERV NUM_ROWS HIGH_VALUE
-------------------- -------------------------------- -------------------- ------------------ ------ ---------- -----------------------------------
IBM T_PART3 P3_1 1 NO 0 TIMESTAMP' 2016-01-01 00:00:00'
IBM T_PART3 P3_2 2 NO 650 TIMESTAMP' 2016-02-01 00:00:00'
IBM T_PART3 P3_3 3 NO 760 TIMESTAMP' 2016-03-01 00:00:00'
IBM T_PART3 SYS_P53133 4 YES 245 TIMESTAMP' 2016-04-01 00:00:00'
IBM T_PART3 SYS_P53134 5 YES 267 TIMESTAMP' 2016-05-01 00:00:00'
IBM T_PART3 SYS_P53130 6 YES 261 TIMESTAMP' 2016-06-01 00:00:00'
IBM T_PART3 SYS_P53132 7 YES 243 TIMESTAMP' 2016-07-01 00:00:00'
IBM T_PART3 SYS_P53131 8 YES 239 TIMESTAMP' 2016-08-01 00:00:00'
IBM T_PART3 SYS_P53135 9 YES 238 TIMESTAMP' 2016-09-01 00:00:00'
IBM T_PART3 SYS_P53136 10 YES 95 TIMESTAMP' 2016-10-01 00:00:00'
- 7. INTERVAL分割槽錶轉換未正常的RANGE分割槽
- ALTER TABLE T_PART3 SET INTERVAL ();
若分割槽表存在maxvalue分割槽,則不能直接轉換為INTERVAL分割槽,需要先將maxvalue分割槽刪除才可轉換。
- 1. 建立存在maxvalue分割槽的分割槽表
-
CREATE TABLE T_PART4(ID NUMBER,NAME VARCHAR2(30),CREATE_DATE TIMESTAMP)
-
PARTITION BY RANGE (CREATE_DATE)
-
(PARTITION P4_1 VALUES LESS THAN (TIMESTAMP' 2016-01-01 00:00:00') ,
-
PARTITION P4_2 VALUES LESS THAN (TIMESTAMP' 2016-02-01 00:00:00') ,
-
PARTITION P4_3 VALUES LESS THAN (TIMESTAMP' 2016-03-01 00:00:00') ,
-
PARTITION P4_4 VALUES LESS THAN (maxvalue)
-
);
-
-
insert into T_PART4
-
select rownum*10,'N'||level,sysdate+dbms_random.value(0,250) from dual connect by level <1040;
-
-
-
exec dbms_stats.gather_table_stats('','T_PART4');
-
- 2. 查詢分割槽資料分部情況
-
select table_owner,table_name,partition_name,partition_position,interval,num_rows, HIGH_VALUE from dba_tab_partitions where table_name = 'T_PART4';
-
-
TABLE_OWNER TABLE_NAME PARTITION_NAME PARTITION_POSITION INTERV NUM_ROWS HIGH_VALUE
-------------------- -------------------------------- -------------------- ------------------ ------ ---------- -----------------------------------
IBM T_PART4 P4_1 1 NO 0 TIMESTAMP' 2016-01-01 00:00:00'
IBM T_PART4 P4_2 2 NO 100 TIMESTAMP' 2016-02-01 00:00:00'
IBM T_PART4 P4_3 3 NO 126 TIMESTAMP' 2016-03-01 00:00:00'
IBM T_PART4 P4_4 4 NO 813 MAXVALUE
- 3. 轉換為按月的INTERVAL分割槽表
- ALTER TABLE T_PART4 SET INTERVAL (NUMTOYMINTERVAL (1,'MONTH'));
ERROR at line 1:
ORA-14759: SET INTERVAL is not legal on this table.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Message:
ORA-14759: SET INTERVAL is not legal on this table.
Cause:
ALTER TABLE SET INTERVAL is only legal on a range partitioned table with a single partitioning column. Additionally this table cannot have a maxvalue partition.
Action:
Use SET INTERVAL only on a valid table
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17086096/viewspace-1973998/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 非分割槽錶轉換成分割槽表
- Oracle分割槽表基礎運維-02範圍分割槽Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(1範圍分割槽)Oracle運維
- 非分割槽錶轉換成分割槽表以及注意事項
- 範圍分割槽
- oracle分割槽表和分割槽表exchangeOracle
- Oracle 12.2之後ALTER TABLE .. MODIFY轉換非分割槽表為分割槽表Oracle
- Oracle 12C新特性-線上把非分割槽錶轉為分割槽表Oracle
- oracle分割槽表和非分割槽表exchangeOracle
- 檢視分割槽範圍
- Oracle查詢Interval partition分割槽表內資料Oracle
- [oracle] expdp 匯出分割槽表的分割槽Oracle
- 分割槽表之自動增加分割槽(11G)
- 【ASK_ORACLE】使用insert語句將普通錶轉換成分割槽表Oracle
- PG的非分割槽表線上轉分割槽表
- Oracle分割槽表基礎運維-07增加分割槽(2 HASH分割槽)Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(3列表分割槽)Oracle運維
- oracle 分割槽表move和包含分割槽表的lob moveOracle
- Oracle分割槽表基礎運維-04列表分割槽Oracle運維
- ORACLE分割槽表梳理系列Oracle
- Oracle分割槽表基礎運維-09刪除分割槽Oracle運維
- Oracle分割槽表基礎運維-05組合分割槽Oracle運維
- Oracle分割槽表基礎運維-03HASH分割槽Oracle運維
- Oracle分割槽表基礎運維-06分割槽表索引Oracle運維索引
- PostgreSQL/LightDB 分割槽表之分割槽裁剪SQL
- Oracle分割槽表基礎運維-01分割槽表分類Oracle運維
- oracle 線上重新定義,普通表改變分割槽表,分割槽表可以更改型別、分割槽欄位等Oracle型別
- oracle將表配置為分割槽表Oracle
- oracle 普通表-分割槽表改造流程Oracle
- interval 分割槽表clob預設表空間指定問題
- oracle分割槽交換(exchange)技術Oracle
- oracle 11g 分割槽表建立(年月日周時分秒)Oracle
- 【MYSQL】 分割槽表MySql
- 對oracle分割槽表的理解整理Oracle
- Oracle SQL調優之分割槽表OracleSQL
- Oracle12c:建立主分割槽、子分割槽,實現自動分割槽插入效果Oracle
- 移動分割槽表和分割槽索引的表空間索引
- Oracle分割槽表基礎運維-07增加分割槽(4 RANGE_HASH)Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(5RANGE_LIST)Oracle運維