i have to create an range partitioned table with two hundred partitions. for eg:
CREATE TABLE emp (
empno NUMBER(4),
ename VARCHAR2(30),
sal NUMBER
)
PARTITION BY RANGE(empno) (
partition e1 values less than (1000) ,
partition e2 values less than (2000) ,
...
partition e200 values less than (MAXVALUE)
);
Is there a way to specify the range interval without writing two hundred lines for just specifing the range?
UPDATE: In 11g exists a feature to specify an interval for range partitions and partitions will be created when you insert into the table.
But I don’t like it and I don’t recommend it for two reasons:
1 You should allways keep the first partition, because is the reference. If you try to drop it you’ll get
SQL Error: ORA-14758: Last partition in the range section cannot be dropped;2 You don’t have control on partition names(AFAIK)
and interval(this is ugly). If, by mistake you insert a value in future some partitions will be skipped and you’ll get fat partitions:(studied a litle and there is no fat partition. Added to example.)
UPDATE2: Nicholas Krasnov indicated in a comment an workaround for point one:
It works, I’ve tested it. However should be noticed that all partitions will freeze, they will be range partitions. If you had gaps will remain(no partition will be added in gaps). So, the reference partition will be the last partition before altering to
interval. This is what the error says:Last partition in the range section cannot be dropped.So, you’ll have a section of range partitioning and a section of Interval partitioning with all its benefits.