If you have Oracle 12.2 or later, this is a snap. Use AUTOMATIC partitioning. E.g.,
CREATE TABLE my_auto_partitioned_table
( id NUMBER,
city_name VARCHAR2(80),
area_name VARCHAR2(80),
other_data VARCHAR2(400) )
PARTITION BY LIST ( city_name, area_name) AUTOMATIC
( PARTITION p_dummy VALUES (null, null) )
;
Pre 12.2, it is possible, with LIST-LIST partitioning, but it is a real pain because you have to pre-create all your partitions and subpartitions. E.g.,
CREATE TABLE my_partitioned_table
( id NUMBER,
city_name VARCHAR2(80),
area_name VARCHAR2(80),
other_data VARCHAR2(400) )
PARTITION BY LIST ( city_name )
SUBPARTITION BY LIST ( area_name )
-- if your area names are generic (e.g., "north"/"south" or "downtown"/"suburbs"),
-- you can use a SUBPARTITION TEMPLATE clause right here...
( PARTITION p_philadelpha VALUES ( 'PHILADELPHIA')
( SUBPARTITION p_philly1 VALUES ('SOUTH PHILLY','WEST PHILLY'),
SUBPARTITION p_philly2 VALUES ('NORTH PHILLY','OLD CITY')
),
PARTITION p_new_york VALUES ( 'NEW YORK')
( SUBPARTITION p_nyc1 VALUES ('SOHO'),
SUBPARTITION p_nyc2 VALUES ('HELL''S KITCHEN')
)
);