间隔分区

间隔分区是Oracle 11g第一版本添加功能。间隔分区以一个分区为起点,根据定义的间隔,让数据自动增加分区。

这样varchar类型的无法作为分区键值

create table interval_example

(
starttime date,
name varchar2(20)
)
partition by range (starttime)
interval(numtoyminterval(1,'month'))
store in(example,learn)

(partition part1 values less than(to_date('2013-12-19','YYYY-MM-DD')));

查询分区

SQL> select t.partition_name from dba_tab_partitions t where t.table_owner=user and t.table_name=upper('interval_example');
PARTITION_NAME
------------------------------
PART1
SQL> insert into interval_example values(to_date('2013-2-4','YYYY-MM-DD'),2);
已创建 1 行。
SQL> commit;
提交完成。
SQL> select t.partition_name from dba_tab_partitions t where t.table_owner=user and t.table_name=upper('interval_example');
PARTITION_NAME
------------------------------
PART1

SQL> select t.partition_name from dba_tab_partitions t where t.table_owner=user and t.table_name=upper('interval_example');
PARTITION_NAME
------------------------------
PART1
SQL> insert into interval_example values(to_date('2014-1-4','YYYY-MM-DD'),2);
已创建 1 行。
SQL> select t.partition_name from dba_tab_partitions t where t.table_owner=user and t.table_name=upper('interval_example');
PARTITION_NAME
------------------------------
PART1
SYS_P101
SQL> commit;
提交完成。
SQL> insert into interval_example values(to_date('2014-4-4','YYYY-MM-DD'),2);
已创建 1 行。
SQL> commit;
提交完成。
SQL> select t.partition_name from dba_tab_partitions t where t.table_owner=user and t.table_name=upper('interval_example');
PARTITION_NAME
------------------------------
PART1
SYS_P101
SYS_P102






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章