分割槽表概念 partitioning table
1)、簡單分割槽
range
list
hash
2)、複合分割槽
range list
range hash
example:
1)、list partition
create table aaa_partitioned
(
id number,
xm varchar2(100),
location varchar2(100),
note varchar2(100),
constraint pk_aaa_partitioned primary key (id)
)
PARTITION BY LIST (location) (
PARTITION aaa_partitioned_beijing VALUES ('beijing'),
PARTITION aaa_partitioned_shanghai VALUES ('shanghai'),
PARTITION aaa_partitioned_tianjin VALUES ('tianjin'),
PARTITION aaa_partitioned_chongqing VALUES ('chongqing'),
PARTITION aaa_partitioned_jinan VALUES (DEFAULT));
2)、range partition
CREATE TABLE aaa_range_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY RANGE (time_id)
(PARTITION SALES_Q1_1998 VALUES LESS THAN (TO_DATE('01-04-1998','DD-MM-YYYY')),
PARTITION SALES_Q2_1998 VALUES LESS THAN (TO_DATE('01-07-1998','DD-MM-YYYY')),
PARTITION SALES_Q3_1998 VALUES LESS THAN (TO_DATE('01-10-1998','DD-MM-YYYY')),
PARTITION SALES_Q4_1998 VALUES LESS THAN (TO_DATE('01-01-1999','DD-MM-YYYY')),
PARTITION SALES_Q1_1999 VALUES LESS THAN (TO_DATE('01-04-1999','DD-MM-YYYY')),
PARTITION SALES_Q2_1999 VALUES LESS THAN (TO_DATE('01-07-1999','DD-MM-YYYY')),
PARTITION SALES_Q3_1999 VALUES LESS THAN (TO_DATE('01-10-1999','DD-MM-YYYY')),
PARTITION SALES_Q4_1999 VALUES LESS THAN (TO_DATE('01-01-2000','DD-MM-YYYY')),
PARTITION SALES_Q1_2000 VALUES LESS THAN (TO_DATE('01-04-2000','DD-MM-YYYY')),
PARTITION SALES_Q2_2000 VALUES LESS THAN (TO_DATE('01-07-2000','DD-MM-YYYY')),
PARTITION SALES_Q3_2000 VALUES LESS THAN (TO_DATE('01-10-2000','DD-MM-YYYY')),
PARTITION SALES_Q4_2000 VALUES LESS THAN (MAXVALUE))
;
增加一個分割槽:
ALTER TABLE aaa_range_sales split PARTITION SALES_Q4_2000 at (TO_DATE('01-01-2001','DD-MM-YYYY')) into (PARTITION SALES_Q4_2000,PARTITION SALES_Q4_2000b)
3)、hash分割槽
CREATE TABLE aaa_hash_products
( product_id NUMBER(6)
, product_name VARCHAR2(50)
, product_description VARCHAR2(2000)
, category_id NUMBER(2)
, weight_class NUMBER(1)
, warranty_period INTERVAL YEAR TO MONTH
, supplier_id NUMBER(6)
, product_status VARCHAR2(20)
, list_price NUMBER(8,2)
, min_price NUMBER(8,2)
, catalog_url VARCHAR2(50)
, CONSTRAINT product_status_lov
CHECK (product_status in ('orderable'
,'planned'
,'under development'
,'obsolete')
) )
PARTITION BY HASH (product_id)
( PARTITION partition1, PARTITION partition2,PARTITION partition3,PARTITION partition4,PARTITION partition5)
4)、range list分割槽
CREATE TABLE customers_part (
customer_id NUMBER(6),
cust_first_name VARCHAR2(20),
cust_last_name VARCHAR2(20),
nls_territory VARCHAR2(30),
credit_limit NUMBER(9,2))
PARTITION BY RANGE (credit_limit)
SUBPARTITION BY LIST (nls_territory)
SUBPARTITION TEMPLATE
(SUBPARTITION east VALUES
('CHINA', 'JAPAN', 'INDIA', 'THAILAND'),
SUBPARTITION west VALUES
('AMERICA', 'GERMANY', 'ITALY', 'SWITZERLAND'),
SUBPARTITION other VALUES (DEFAULT))
(PARTITION p1 VALUES LESS THAN (1000),
PARTITION p2 VALUES LESS THAN (2500),
PARTITION p3 VALUES LESS THAN (MAXVALUE));
5)、range hash分割槽
CREATE TABLE composite_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY RANGE (time_id)
SUBPARTITION BY HASH (channel_id)
(PARTITION SALES_Q1_1998 VALUES LESS THAN (TO_DATE('01-APR-1998','DD-MON-YYYY')),
PARTITION SALES_Q2_1998 VALUES LESS THAN (TO_DATE('01-JUL-1998','DD-MON-YYYY')),
PARTITION SALES_Q3_1998 VALUES LESS THAN (TO_DATE('01-OCT-1998','DD-MON-YYYY')),
PARTITION SALES_Q4_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
PARTITION SALES_Q1_1999 VALUES LESS THAN (TO_DATE('01-APR-1999','DD-MON-YYYY')),
PARTITION SALES_Q2_1999 VALUES LESS THAN (TO_DATE('01-JUL-1999','DD-MON-YYYY')),
PARTITION SALES_Q3_1999 VALUES LESS THAN (TO_DATE('01-OCT-1999','DD-MON-YYYY')),
PARTITION SALES_Q4_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
PARTITION SALES_Q1_2000 VALUES LESS THAN (TO_DATE('01-APR-2000','DD-MON-YYYY')),
PARTITION SALES_Q2_2000 VALUES LESS THAN (TO_DATE('01-JUL-2000','DD-MON-YYYY'))
SUBPARTITIONS 8,
PARTITION SALES_Q3_2000 VALUES LESS THAN (TO_DATE('01-OCT-2000','DD-MON-YYYY'))
(SUBPARTITION ch_c,
SUBPARTITION ch_i,
SUBPARTITION ch_p,
SUBPARTITION ch_s,
SUBPARTITION ch_t),
PARTITION SALES_Q4_2000 VALUES LESS THAN (MAXVALUE)
SUBPARTITIONS 4)
;
hash分割槽名稱,可以自定義,也可以系統產生
分割槽表注意事項:
1、分割槽表可以跨tablespace,建議跨tablespace提高io效能
2、tablespace必須是同樣大小的db_block_size
3、索引:local global之分
4、根據需要可以分割槽可以拆分或者合併。split/merge
5、操作具體的分割槽 同 操作具體的table有n多相似
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70612/viewspace-1024091/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 表分割槽操作大全_table partitioning
- SQL Server 表分割槽(partitioned table/Data Partitioning)SQLServer
- 分割槽表PARTITION table
- Oracle分割槽表(Partition Table)Oracle
- 分割槽表PARTITION table(轉)
- ORACLE分割槽表的概念及操作Oracle
- oracle 分割槽表 概念以及常用操作Oracle
- 【學習筆記】分割槽表和分割槽索引——概念部分(一)筆記索引
- Oracle 12.2之後ALTER TABLE .. MODIFY轉換非分割槽表為分割槽表Oracle
- 關於分割槽表的概念及操作
- oracle分割槽表和分割槽表exchangeOracle
- 全面學習分割槽表及分割槽索引(13)--分隔表分割槽索引
- oracle分割槽表和非分割槽表exchangeOracle
- Oracle分割槽表及分割槽索引Oracle索引
- INTERVAL分割槽表鎖分割槽操作
- 全面學習分割槽表及分割槽索引(9)--刪除表分割槽索引
- 全面學習分割槽表及分割槽索引(11)--合併表分割槽索引
- 全面學習分割槽表及分割槽索引(12)--修改list表分割槽索引
- 學習筆記】分割槽表和分割槽索引——新增表分割槽(二)筆記索引
- 如何查詢分割槽表的分割槽及子分割槽
- 使用split對分割槽表再分割槽
- 簡單ORACLE分割槽表、分割槽索引Oracle索引
- rebuild分割槽表分割槽索引的方法Rebuild索引
- 分割槽表及分割槽索引建立示例索引
- 全面學習分割槽表及分割槽索引(10)--交換分割槽索引
- PLSQL根據分割槽表的分割槽名批次truncate分割槽SQL
- 全面學習分割槽表及分割槽索引(8)--增加和收縮表分割槽索引
- 【學習筆記】分割槽表和分割槽索引——分割槽表的其他管理(三)筆記索引
- 範圍分割槽表和INTERVAL分割槽表對於SPLIT分割槽的區別
- 【MYSQL】 分割槽表MySql
- postgresql分割槽表SQL
- Oracle 表分割槽Oracle
- MySQL 分割槽表MySql
- oracle分割槽表Oracle
- MySQL分割槽表MySql
- oracle表分割槽Oracle
- Oracle 分割槽表Oracle
- [oracle] expdp 匯出分割槽表的分割槽Oracle