总结了11g partition new feature
11G Introduced partition extensions:
-Interval partitioning
-REF partitioning
-More Composite Partitioning
-Virtual Column-based partitioning
-System Partitioning
-Introduced Partition Advisor.


Partition Types
Let us discuss each of the above features briefly:

Range partitioning: The data is distributed based on a range of values of the partitioning key. For example, if we choose a date column as the partitioning key, the partition “JAN-2007” will contain all the rows that have the partition key values between 01-JAN-2007 and 31-JAN-2007 (assuming the range of the partition is from first of the month to the last date in the month).

Hash Partitioning: A hash algorithm is applied to the partitioning key to determine the partition for a given row. This provides I/O balancing, but cannot be used for range or inequality queries.

List Partitioning: The data distribution is defined by a list of values of the partitioning key. This is useful for discrete lists. e.g: Regions, States etc.

Composite Partitioning: A combination of 2 data distribution methods are used to create a composite partition. The table is initially partitioned by the first data distribution method and then each partition is sub-partitioned by the second data distribution method. The following composite partitions are available:
Range-Hash, Range-List, Range-Range, List-Range, List-List and List-Hash.

Index organized tables (tables where index and data are stored together) supports partitioning by Range, List or Hash in 10G. However, composite partitions are not supported on Index organized tables.

1.Interval Partitioning: Introduced in 11g, interval partitions are extensions to range partitioning. These provide automation for equi-sized range partitions. Partitions are created as metadata and only the start partition is made persistent. The additional segments are allocated as the data arrives. The additional partitions and local indexes are automatically created.


CREATE TABLE SALES_PART
(TIME_ID NUMBER,
REGION_ID NUMBER,
ORDER_ID NUMBER,
ORDER_DATE DATE,
SALES_QTY NUMBER(10,2),
SALES_AMOUNT NUMBER(12,2)
)

PARTITION BY RANGE (ORDER_DATE)
INTERVAL (NUMTOYMINTERVAL(1,’month’) store in (x,y)
(PARTITION p_first VALUES LESS THAN (’01-JAN-2006′);

The numtoyminterval function converts a number to an INTERVAL YEAR TO MONTH literal (‘YEAR’ or ’MONTH’).
The numtodsinterval function converts a number to an INTERVAL DAY literal (‘x’,’DAY’).
还没有详细的资料表明oracle如何控制分区属性,如自增长分区在tablespace之中的分配,以及大小等等

2.REF Partitioning: This partitioning scheme has been introduced with the assumption that related tables would benefit from same partitioning strategy. The detail table inherits the partitioning strategy of the master table through PK-FK relationship. There is no need for the partitioning key to be stored in the detail table and by specifying “PARTITION BY REFERENCE” keyword, the detail table inherits the partitioning strategy of the master table.


CREATE TABLE orders
( order_id NUMBER(12),
order_date DATE,
order_mode VARCHAR2(8),
customer_id NUMBER(6),
CONSTRAINT orders_pk PRIMARY KEY(order_id)
)
PARTITION BY RANGE(order_date)
(PARTITION Q1_2005 VALUES LESS THAN
(TO_DATE(’2005-4-1′,’yyyy-mm-dd’)),
PARTITION Q2_2005 VALUES LESS THAN
(TO_DATE(’2005-7-1′,’yyyy-mm-dd’)),
PARTITION Q3_2005 VALUES LESS THAN
(TO_DATE(’2005-10-1′,’yyyy-mm-dd’)),
PARTITION Q4_2005 VALUES LESS THAN
(TO_DATE(’2006-1-1′,’yyyy-mm-dd’)))

CREATE TABLE order_items
( order_id NUMBER(12) NOT NULL,
line_item_id NUMBER(3) NOT NULL,
product_id NUMBER(6) NOT NULL,
unit_price NUMBER(8,2),
quantity NUMBER(8),
CONSTRAINT order_items_fk
FOREIGN KEY(order_id) REFERENCES orders(order_id)
)
PARTITION BY REFERENCE(order_items_fk)


父表的分区发生变化,子表分区也会自动适应,而单独修改子表分区则不被允许。

3.Virtual Column Based partitioning: In the previous versions of Oracle, a table could be partitioned only if the partition key physically existed in the table. The new functionality in Oracle 11G, “Virtual columns”, removes this restriction and allows partitioning key to be defined by an expression that uses one or more columns of a table. The virtual columns are stored as metadata only.

借用一个网友的例子:


create table sales
(
sales_id number,
cust_id number,
sales_amt number,
sale_category varchar2(6)
generated always as
(
case
when sales_amt <= 10000 then 'LOW' when sales_amt > 10000
and sales_amt <= 100000 then case when cust_id < 101 then 'LOW' when cust_id between 101 and 200 then 'MEDIUM' else 'MEDIUM' end when sales_amt > 100000
and sales_amt <= 1000000 then case when cust_id < 101 then 'MEDIUM' when cust_id between 101 and 200 then 'HIGH' else 'ULTRA' end else 'ULTRA' end ) virtual ) partition by list (sale_category) ( partition p_low values ('LOW'), partition p_medium values ('MEDIUM'), partition p_high values ('HIGH'), partition p_ultra values ('ULTRA') ) ; Table created. SQL>
SQL> insert into sales (sales_id,cust_id,sales_amt) values (1,1,100);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from sales partition (p_low);

SALES_ID CUST_ID SALES_AMT SALE_C
———- ———- ———- ——
1 1 100 LOW

4.System Partitioning

CREATE TABLE syspar (c1 int, c2 int)
PARTITION BY SYSTEM
(
PARTITION p1 TABLESPACE tbs_1,
PARTITION p2 TABLESPACE tbs_2,
PARTITION p3 TABLESPACE tbs_3,
PARTITION p4 TABLESPACE tbs_4
);


由SQL语句决定插入哪一个分区 like: insert into syspar partition (x) values (1,2); 这种类型的分区将不支持Partition Split操作,也不支持create table as select操作。

5.More Composite Partitioning

现在Range,List,Interval都可以作为Top level分区,而Second level则可以是Range,List,Hash,也就是在11g中可以有3*3=9种复合分区,满足更多的业务需求。

6.Introduced Partition Advisor

The Partition Advisor is part of the SQL Access Advisor of EM in 11g . The Partition Advisor can recommend a partitioning strategy for a table based on a supplied workload of SQL statements which can be supplied by the SQL Cache, a SQL Tuning set, or be defined by the user.