I have three columns that uniquely identify a row - id, code and region. I'm trying to create a partition on ID and two subpartitions on CODE and REGION.
I'm not sure if this is the best way to do it, so I'm open to suggestions. I'm not really using the USERS tablespace, but I think each column should have its own tablespace.
This is what I have so far, but I'm getting a syntax error:
CREATE TABLE t
( id number
, code number
, region number
, dt_effective date
)
PARTITION BY RANGE (id)
SUBPARTITION BY RANGE (code)
SUBPARTITION TEMPLATE
(
SUBPARTITION part_code1 VALUES LESS THAN (500000) COMPRESS TABLESPACE users
, SUBPARTITION part_code2 VALUES LESS THAN (1000000) COMPRESS TABLESPACE users
, SUBPARTITION part_code3 VALUES LESS THAN (1500000) COMPRESS TABLESPACE users
, SUBPARTITION part_code4 VALUES LESS THAN (2000000) COMPRESS TABLESPACE users
, SUBPARTITION part_code5 VALUES LESS THAN (2500000) COMPRESS TABLESPACE users
, SUBPARTITION part_code6 VALUES LESS THAN (3000000) COMPRESS TABLESPACE users
, SUBPARTITION part_code7 VALUES LESS THAN (MAXVALUE) COMPRESS TABLESPACE users
)
SUBPARTITION BY LIST (region)
SUBPARTITION TEMPLATE
(
SUBPARTITION part_region1 VALUES (1) COMPRESS TABLESPACE users
, SUBPARTITION part_region2 VALUES (2) COMPRESS TABLESPACE users
)
(
PARTITION part_id1 VALUES LESS THAN (10001) COMPRESS TABLESPACE users
, PARTITION part_id2 VALUES LESS THAN (20001) COMPRESS TABLESPACE users
, PARTITION part_id3 VALUES LESS THAN (30001) COMPRESS TABLESPACE users
, PARTITION part_id4 VALUES LESS THAN (40001) COMPRESS TABLESPACE users
, PARTITION part_id5 VALUES LESS THAN (50001) COMPRESS TABLESPACE users
, PARTITION part_id6 VALUES LESS THAN (60001) COMPRESS TABLESPACE users
, PARTITION part_id7 VALUES LESS THAN (MAXVALUE) COMPRESS TABLESPACE users
)
/
SUBPARTITION BY LIST (region)
*
ERROR at line 19:
ORA-00922: missing or invalid option
--sample data
insert into t
values(1,1,1,sysdate-7)
/
insert into t
values(11000,500050,1,sysdate-7)
/
insert into t
values(20010,2000010,1,sysdate-7)
/
insert into t
values(40003,2800000,2,sysdate-7)
/
insert into t
values(65000,3500000,2,sysdate-7)
/