使用Oracle Database 11g建立Interval分割槽表
使用Oracle Database 11g可以建立新型別的Interval分割槽表,Interval型別分割槽表,可以根據載入資料,自動建立指定間隔的分割槽。
比如建立按月分割槽的分割槽表:
注意如果你的INTERVAL指定錯誤,則資料庫會報出如下錯誤:
create table sales
(
sales_id number,
sales_dt date
)
partition by range (sales_dt)
INTERVAL (NUMTODSINTERVAL(1,'day'))
(
partition p1410101 values less than (to_date('2014-01-01','yyyy-mm-dd'))
);
create index id_local_index on sales(sales_id) local;
begin
for i in 0 .. 5 loop
insert into sales values(i,trunc(sysdate,'YYYY')+i);
end loop;
commit;
end;
/
TEST@ sms> select table_name,partition_name from user_tab_partitions;
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
SALES SYS_P109
SALES SYS_P108
SALES SYS_P110
SALES SYS_P111
SALES SYS_P112
SALES SYS_P113
SALES P1410101
7 rows selected.
TEST@ sms> select INDEX_NAME,PARTITION_NAME from user_ind_partitions;
INDEX_NAME PARTITION_NAME
------------------------------ ------------------------------
ID_LOCAL_INDEX SYS_P108
ID_LOCAL_INDEX SYS_P109
ID_LOCAL_INDEX SYS_P110
ID_LOCAL_INDEX SYS_P111
ID_LOCAL_INDEX SYS_P112
ID_LOCAL_INDEX SYS_P113
ID_LOCAL_INDEX P1410101
7 rows selected.
TEST@ sms> select * from sales partition(P1410101);
no rows selected
TEST@ sms> select * from sales partition(SYS_P108);
SALES_ID SALES_DT
---------- ------------------
0 01-JAN-14
TEST@ sms> select * from sales partition(SYS_P109);
SALES_ID SALES_DT
---------- ------------------
1 02-JAN-14
這一特性極大簡化了分割槽表的維護工作。
select to_char(sysdate,'yyyy-mm-dd') from dual;
select table_name,partition_name from user_tab_partitions;
select INDEX_NAME,PARTITION_NAME from user_ind_partitions;
比如建立按月分割槽的分割槽表:
Create table intervalpart
(c1 number, c2 varchar2(10) , c3 date)
partition by range (c3)
interval(numtoyminterval(1,'MONTH'))
(
partition part1 values less than (to_date('09/15/2007','MM/DD/YYYY')),
partition part2 values less than (to_date('10/15/2007','MM/DD/YYYY')),
partition part3 values less than (to_date('11/15/2007','MM/DD/YYYY'))
)
/
注意如果你的INTERVAL指定錯誤,則資料庫會報出如下錯誤:
ORA-14752: Interval expression is not a constant of the correct type下面建立一個以天為間隔的分割槽表:
create table sales
(
sales_id number,
sales_dt date
)
partition by range (sales_dt)
INTERVAL (NUMTODSINTERVAL(1,'day'))
(
partition p1410101 values less than (to_date('2014-01-01','yyyy-mm-dd'))
);
create index id_local_index on sales(sales_id) local;
begin
for i in 0 .. 5 loop
insert into sales values(i,trunc(sysdate,'YYYY')+i);
end loop;
commit;
end;
/
TEST@ sms> select table_name,partition_name from user_tab_partitions;
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
SALES SYS_P109
SALES SYS_P108
SALES SYS_P110
SALES SYS_P111
SALES SYS_P112
SALES SYS_P113
SALES P1410101
7 rows selected.
TEST@ sms> select INDEX_NAME,PARTITION_NAME from user_ind_partitions;
INDEX_NAME PARTITION_NAME
------------------------------ ------------------------------
ID_LOCAL_INDEX SYS_P108
ID_LOCAL_INDEX SYS_P109
ID_LOCAL_INDEX SYS_P110
ID_LOCAL_INDEX SYS_P111
ID_LOCAL_INDEX SYS_P112
ID_LOCAL_INDEX SYS_P113
ID_LOCAL_INDEX P1410101
7 rows selected.
TEST@ sms> select * from sales partition(P1410101);
no rows selected
TEST@ sms> select * from sales partition(SYS_P108);
SALES_ID SALES_DT
---------- ------------------
0 01-JAN-14
TEST@ sms> select * from sales partition(SYS_P109);
SALES_ID SALES_DT
---------- ------------------
1 02-JAN-14
這一特性極大簡化了分割槽表的維護工作。
select to_char(sysdate,'yyyy-mm-dd') from dual;
select table_name,partition_name from user_tab_partitions;
select INDEX_NAME,PARTITION_NAME from user_ind_partitions;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27036311/viewspace-1302473/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE 11g 範圍分割槽錶轉換INTERVAL分割槽表Oracle
- INTERVAL分割槽表鎖分割槽操作
- Oracle 建立分割槽表Oracle
- 11g分佈表新特性——Interval分割槽(上)
- 11g分佈表新特性——Interval分割槽(下)
- 建立oracle10g 11g分割槽表Oracle
- Oracle Interval Partition 自動分割槽表-實驗Oracle
- [間隔分割槽]Oracle10g、11g建立間隔分割槽表Oracle
- Oracle11g INTERVAL分割槽新增分割槽策略Oracle
- oracle 11g 分割槽表Oracle
- Oracle 分割槽表的建立Oracle
- Oracle查詢Interval partition分割槽表內資料Oracle
- 範圍分割槽表和INTERVAL分割槽表對於SPLIT分割槽的區別
- 11g分割槽新特性之interval partition
- oracle10g 11g分割槽表建立舉例Oracle
- [引用分割槽表]Oracle 11g新特性之引用分割槽表Oracle
- oracle 11g 分割槽表建立(年月日周時分秒)Oracle
- ORACLE 11G分割槽表新功能:列表--範圍分割槽Oracle
- Oracle分割槽表的使用Oracle
- Oracle Interval Partition 生產環境-建立表FACT_STORAGE_SHEET為分割槽的過程Oracle
- 分割槽表及分割槽索引建立示例索引
- oracle分割槽表和分割槽表exchangeOracle
- DATE型別INTERVAL分割槽型別
- Oracle中分割槽表的使用Oracle
- Oracle分割槽表及分割槽索引Oracle索引
- oracle分割槽表和非分割槽表exchangeOracle
- 週六直播充電:探究Oracle分割槽表建立和使用Oracle
- Oracle 表分割槽Oracle
- oracle分割槽表Oracle
- oracle表分割槽Oracle
- Oracle 分割槽表Oracle
- 教程:如何使用DataLakeAnalytics建立分割槽表
- OceaBase 分割槽表建立技巧
- 簡單ORACLE分割槽表、分割槽索引Oracle索引
- ORACLE分割槽表的使用和管理Oracle
- Oracle分割槽之五:建立分割槽索引總結Oracle索引
- ORACLE分割槽表管理Oracle
- oracle 建立所有分割槽索引Oracle索引