The table is created with composite range-list partitioning. Composite range-list partitioning partitions data using the range method, and within each partition, subpartitions the data further using the list method. The range partition uses the value of sales_date column and list subpartition uses the value of the state_code column. For example, a value for sales_date that is less than 01-OCT-2014 with a value for state_code that is equal to CT would be stored in the sales_q3_region_east_2014 partition.
Create the QUARTERLY_REGIONAL_SALES table
CREATE TABLE quarterly_regional_sales (
product_id NUMBER(6),
customer_id NUMBER,
channel_id CHAR(1),
promo_id NUMBER(6),
sale_date DATE,
quantity_sold INTEGER,
amount_sold NUMBER(10,2),
store_name VARCHAR(30),
state_code VARCHAR(2)
)
PARTITION BY RANGE (sale_date)
SUBPARTITION BY LIST (state_code)
(PARTITION sales_q1_2014 VALUES LESS THAN (TO_DATE('01-APR-2014','dd-MON-yyyy'))
(SUBPARTITION sales_q1_region_east_2014
VALUES ('CT','MA','MD','ME','NH','NJ','NY','PA','VA'),
SUBPARTITION sales_q1_region_west_2014
VALUES ('AZ','CA','CO','NM','NV','OR','UT','WA'),
SUBPARTITION sales_q1_region_south_2014
VALUES ('AL','AR','GA','KY','LA','MS','TN','TX'),
SUBPARTITION sales_q1_region_central_2014
VALUES ('IA','IL','KS','MI','MO','ND','OH','OK','SD'),
SUBPARTITION sales_q1_region_other_2014
VALUES ('HI','PR'),
SUBPARTITION sales_q1_region_null_2014
VALUES (NULL),
SUBPARTITION
VALUES (DEFAULT)
),
PARTITION sales_q2_2014 VALUES LESS THAN (TO_DATE('01-JUL-2014','dd-MON-yyyy'))
(SUBPARTITION sales_q2_region_east_2014
VALUES ('CT','MA','MD','ME','NH','NJ','NY','PA','VA'),
SUBPARTITION sales_q2_region_west_2014
VALUES ('AZ','CA','CO','NM','NV','OR','UT','WA'),
SUBPARTITION sales_q2_region_south_2014
VALUES ('AL','AR','GA','KY','LA','MS','TN','TX'),
SUBPARTITION sales_q2_region_central_2014
VALUES ('IA','IL','KS','MI','MO','ND','OH','OK','SD'),
SUBPARTITION sales_q2_region_other_2014
VALUES ('HI','PR'),
SUBPARTITION sales_q2_region_null_2014
VALUES (NULL),
SUBPARTITION
VALUES (DEFAULT)
),
PARTITION sales_q3_2014 VALUES LESS THAN (TO_DATE('01-OCT-2014','dd-MON-yyyy'))
(SUBPARTITION sales_q3_region_east_2014
VALUES ('CT','MA','MD','ME','NH','NJ','NY','PA','VA'),
SUBPARTITION sales_q3_region_west_2014
VALUES ('AZ','CA','CO','NM','NV','OR','UT','WA'),
SUBPARTITION sales_q3_region_south_2014
VALUES ('AL','AR','GA','KY','LA','MS','TN','TX'),
SUBPARTITION sales_q3_region_central_2014
VALUES ('IA','IL','KS','MI','MO','ND','OH','OK','SD'),
SUBPARTITION sales_q3_region_other_2014
VALUES ('HI','PR'),
SUBPARTITION sales_q3_region_null_2014
VALUES (NULL),
SUBPARTITION
VALUES (DEFAULT)
),
PARTITION sales_q4_2014 VALUES LESS THAN (TO_DATE('01-JAN-2015','dd-MON-yyyy'))
(SUBPARTITION sales_q4_region_east_2014
VALUES ('CT','MA','MD','ME','NH','NJ','NY','PA','VA'),
SUBPARTITION sales_q4_region_west_2014
VALUES ('AZ','CA','CO','NM','NV','OR','UT','WA'),
SUBPARTITION sales_q4_region_south_2014
VALUES ('AL','AR','GA','KY','LA','MS','TN','TX'),
SUBPARTITION sales_q4_region_central_2014
VALUES ('IA','IL','KS','MI','MO','ND','OH','OK','SD'),
SUBPARTITION sales_q4_region_other_2014
VALUES ('HI','PR'),
SUBPARTITION sales_q4_region_null_2014
VALUES (NULL),
SUBPARTITION
VALUES (DEFAULT)
),
PARTITION sales_q1_2015 VALUES LESS THAN (TO_DATE('01-APR-2015','dd-MON-yyyy'))
(SUBPARTITION sales_q1_region_east_2015
VALUES ('CT','MA','MD','ME','NH','NJ','NY','PA','VA'),
SUBPARTITION sales_q1_region_west_2015
VALUES ('AZ','CA','CO','NM','NV','OR','UT','WA'),
SUBPARTITION sales_q1_region_south_2015
VALUES ('AL','AR','GA','KY','LA','MS','TN','TX'),
SUBPARTITION sales_q1_region_central_2015
VALUES ('IA','IL','KS','MI','MO','ND','OH','OK','SD'),
SUBPARTITION sales_q1_region_other_2015
VALUES ('HI','PR'),
SUBPARTITION sales_q1_region_null_2015
VALUES (NULL),
SUBPARTITION
VALUES (DEFAULT)
)
)