在Oracle 11g之前,如果我們往一個沒有匹配到滿足分區(qū)的RANGE分區(qū)寫記錄的時候會報 ORA-14400: inserted partition key does not map to any partition,因為這個原因我已經(jīng)半夜起來過好幾次。
如果Oracle在更新記錄或者新增記錄的時候發(fā)現(xiàn)沒有匹配的分區(qū)能自動分區(qū)該多好,在oracle11g中oracle實現(xiàn)了這個功能。-
看個簡單的例子。
etl@DWTEST19> create table part_01
2 (
3 col01 date
4 )
5 partition by range(col01)
6 (
7 partition p201001 values less than ( to_date('20100201','yyyymmdd') ),
8 partition p201002 values less than ( to_date('20100301','yyyymmdd') )
9 )
10 /
Table created.
etl@DWTEST19> insert into part_01 values( to_date('20100301','yyyymmdd'));
insert into part_01 values( to_date('20100301','yyyymmdd'))
*
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
可以看出在沒有分區(qū)滿足的時候會報錯。
下面看看Oracle11g提供的間隔分區(qū)功能
etl@DWTEST>create table part_01
2 (
3 col01 date
4 )
5 partition by range(col01)
6 interval (numtoyminterval(1,'MONTH'))
7 (
8 partition p201001 values less than ( to_date('20100201','yyyymmdd') )
9 )
10 /
Table created.
Elapsed: 00:00:00.08
etl@DWTEST>insert into part_01 values( to_date('20101001','yyyymmdd') );
1 row created.
Elapsed: 00:00:00.07
etl@DWTEST>select partition_name,high_value
2 from user_tab_partitions
3 where table_name='PART_01';
PARTITION_NAME HIGH_VALUE
--------------- --------------------------------------------------
P201001 TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:
MI:SS', 'NLS_CALENDAR=GREGORIAN')
SYS_P36675 TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:
MI:SS', 'NLS_CALENDAR=GREGORIAN')
Elapsed: 00:00:00.45
etl@DWTEST>insert into part_01 values( to_date('20100901','yyyymmdd') );
1 row created.
Elapsed: 00:00:01.37
etl@DWTEST>select partition_name,high_value
2 from user_tab_partitions
3 where table_name='PART_01';
PARTITION_NAME HIGH_VALUE
--------------- --------------------------------------------------
P201001 TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:
MI:SS', 'NLS_CALENDAR=GREGORIAN')
SYS_P36675 TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:
MI:SS', 'NLS_CALENDAR=GREGORIAN')
SYS_P36676 TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:
MI:SS', 'NLS_CALENDAR=GREGORIAN')
Elapsed: 00:00:00.43
可以看出Oracle很好的為我們處理了加分區(qū)的操作。
但是,分區(qū)名,分區(qū)名怎么指定呢?
本文出自:億恩科技【1tcdy.com】
服務(wù)器租用/服務(wù)器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|