--创建表
create table sales1
(
sales_ID number,
product_id varchar2(5),
sale_date date not null
)
--创建分区
PARTITION by range (sale_date)
(
PARTITION p1 values less than (to_date('2013-04-01','yyyy-mm-dd')),
PARTITION p2 values less than (to_date('2013-07-01','yyyy-mm-dd')),
PARTITION p3 values less than (to_date('2013-10-01','yyyy-mm-dd')),
PARTITION p4 values less than (to_date('2014-01-01','yyyy-mm-dd')),
PARTITION p5 values less than (maxvalue)
);
--查询语句
select * from sales1 partition(p5)
--查询分区情况
select table_name,partition_name
from user_tab_partitions
where table_name=UPPER('sales1')
--间隔表分区
create table sales2
(
sales_ID number,
product_id varchar2(5),
sale_date date not null
)
PARTITION by range (sale_date)
interval(numtoyminterval(3,'month'))
(partition p1 values less than(to_date('2013-04-01','yyyy-mm-dd')));