Partitioning Tables  «Prev  Next»

Lesson 3Partitioning Object Tables
ObjectiveDefine how to Partition an Object Table.

Partitioning Object Tables

Oracle has the ability to partition object tables. Just like partitioning relational tables, you must define a column or list of columns in the object table that defines the division points for each partition. The column has to be a standard Oracle data type, such as NUMBER or VARCHAR2.
The following Slide Show illustrates how to partition an object table.
Object Tablespace 1
1) Object Tablespace 1

Object Tablespace 2
2) Object Tablespace 2

Object Tablespace 3
3) Object Tablespace 3

Object Tablespace 4
4) Object Tablespace 4

Object Tablespace 5
5) Object Tablespace 5


Partitioned Object Table

Subtype Attribute for Partitioning

Let us look at another example where you use a subtype attribute for partitioning. In this case, you must base your partitioning on a subtype column rather than a column in the table's object type. The syntax is only slightly different: you must identify the table column and the subtype column in the PARTITION BY RANGE clause.

CREATE TABLE PARTITIONED_CUSTOMER
OF CUSTOMER_TYPE
TABLESPACE USERS PCTFREE 20
PARTITION BY RANGE (FULL_ADDRESS.CITY)
(PARTITION NAME_A_F VALUES LESS THAN ('G'),
PARTITION NAME_G_P VALUES LESS THAN ('Q'),
PARTITION NAME_Q_Z VALUES LESS THAN
   (MAXVALUE))

This example uses the object types found in the Course Project and shows how to specify the CITY subtype column in the PARTITION BY RANGE clause. The next lesson covers how to partition a table with LOBs.

Create Partitioned Table Object

View the paragraph below to practice partitioning an object-organized table.

Create Partitioned Object Table

During the simulation, you created a partitioned object table. The code you created should look something like this:
CREATE TYPE GAME_TYPE  AS OBJECT
(GAME_ID NUMBER,
 GAME_NAME VARCHAR2(50),
 CATEGORY VARCHAR2(50),
 DIFFICULTY VARCHAR2(10))
/
CREATE TABLE GAMES OF GAME_TYPE
TABLESPACE USERS PCTFREE 20
PARTITION BY RANGE (GAME_NAME)
(PARTITION NAME_A_K VALUES LESS THAN ('J'),
 PARTITION NAME_J_R VALUES LESS THAN ('S'),
 PARTITION NAME_S_Z VALUES LESS THAN (MAXVALUE))
/