Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.2)

E13403-10


oracle.javatools.db.ora
Class OracleTablePartitions

java.lang.Object
  extended by oracle.javatools.db.AbstractDBObject
      extended by oracle.javatools.db.AbstractChildDBObject
          extended by oracle.javatools.db.ora.OracleTablePartitions

All Implemented Interfaces:
ChildDBObject, DBObject, Copyable, DynamicPropertySet

public class OracleTablePartitions
extends AbstractChildDBObject

OracleTablePartitions encapsulate the properties of an Oracle table's partitions and subpartitions. The partitions and subpartitions can be defined individually or by models which the database uses to create individual (sub)partitions. Where both individual and model definitions are allowed, the individual definitions overide the model. For example the following DDL creates a table with 3 partitions defined by a model:

    create table HASH1
     ( C1 number
     , C2 number
     )
     partition by hash(C1)
       partitions 3 store in ( USERS, EXAMPLE )
 

The following DDL creates a table with individually defined partitions:

      create table HASH2
      ( C1 number
      , C2 number
      )
      partition by hash(C1)
      ( partition P1 tablespace USERS
       ,partition P2 tablespace EXAMPLE
      )
 

It isn't permissible to define both model and individual partitions, but it is permissible to define model and individual subpartitions :

      create table RANGE_HASH1
      ( C1 number
      , C2 number
      )
      partition by range(C1)
      subpartition by hash(C2) subpartitions 2 store in (EXAMPLE)
      ( partition P100 values less than(100)
        ( subpartition
         ,subpartition RANGE_HASH1_SP1
         ,subpartition RANGE_HASH1_SP2
        )
       ,partition P500 values less than(500)
       ,partition PMAX values less than(maxvalue)
          subpartitions 5 store in (USERS)
      )
 

In this example, partition P_100 has 3 individually defined subpartitions, partition P500 has 2 subpartitions defined by the subpartitions 2 model, and partition PMAX has 5 subpartitions defined by its own subpartitions model. The subpartition definitions within P100 and PMAX are known as partition level subpartitions. Instead of just defining how many subpartitions are created for partitions that don't define partition level subpartitions, a subpartition template can be defined instead :

      create table RANGE_HASH2
      ( C1 number
      , C2 number
      )
      partition by range(C1)
      subpartition by hash(C2) subpartition template
      ( subpartition RANGE_HASH2_SP1
       ,subpartition RANGE_HASH2_SP2
      )
      ( partition P100 values less than(100)
        ( subpartition
         ,subpartition RANGE_HASH2_SP3
         ,subpartition RANGE_HASH2_SP4
        )
       ,partition P500 values less than(500)
       ,partition PMAX values less than(maxvalue)
      )
 

In this example, partitions P500 is allocated subpartitions called P500_RANGE_HASH2_SP1, and P500_RANGE_HASH2_SP2, and partition PMAX is allocated subpartitions PMAX_RANGE_HASH2_SP1, and PMAX_RANGE_HASH2_SP2.

If the table defines LOB or VARRAY columns, they may be further defined within an individual partition or subpartition :

   create table RANGE_HASH3
    ( C1 number
    , C2 number
    , C_CLOB clob
    , C_BLOB blob
    , C_VARRAY T_VARRAY
    )
    partition by range(C1)
    subpartition by hash(C2)
    ( partition P100 values less than(100)
        lob(C_BLOB) store as RANGE_HASH3_P100_SEG1
        ( subpartition RANGE_HASH3_SP1
            lob(C_CLOB) store as RANGE_HASH3_SP1_SEG1( tablespace USERS)
         ,subpartition RANGE_HASH3_SP2
            varray C_VARRAY store as lob RANGE_HASH3_SP2_SEG1
        )
     ,partition PMAX values less than(maxvalue)
        ( subpartition RANGE_HASH3_SP3
            lob(C_CLOB) store as RANGE_HASH3_SP1_SEG3( tablespace USERS)
            varray C_VARRAY store as lob RANGE_HASH3_SP3_SEG1
        )
    )
 

The OracleTablePartitions class defines

  1. PARTITION_TYPE : the type of partition {RANGE, LIST, HASH} or subpartition {LIST, HASH}. The property is mandatory.
  2. OBJECT_TYPE : the usage of an object of this class {PARTITION, SUBPARTITION, SUBPARTITION_TEMPLATE, PARTITION_LEVEL_SUBPARTITION}. The property is mandatory.
  3. COLUMNS : the columns that are used to determine which partition and/or subpartition a row belongs. The property is not valid for PARTITION_LEVEL_SUBPARTITION.
  4. HASH_QUANTITY : the number (sub)partitions defined by a HASH (sub)partition model. The property is only valid when PARTITION_TYPE = HASH.
  5. HASH_QUANTITY_TABLESPACES : the tablespaces of a HASH (sub)partition model. The property is only valid when PARTITION_TYPE = HASH.
  6. PARTITIONS : a collection of individual (sub)partitions, each defined by class TablePartition. The property may be empty.
  7. SUBPARTITION_MODEL : a reference to an OracleTablePartitions defining the subpartition model of a composite RANGE PARTITION.

A reference to an OracleTablePartitions object is stored on :

  1. Table to hold the table's partitions. It is held as property OracleTablePartitions.KEY when property OracleDatabase.PARTITIONED_TABLE_PROPERTY is true.
  2. OracleTablePartitions to hold a composite partition's subpartition model.
  3. TablePartition to hold a partition's partition level subpartitions.

The usage of an OracleTablePartitions object is determined by its object type:

  1. When the object represents a table's partitions, its object type is PARTITION.
  2. When the object represents a partition's partition level subpartitions, its object type is PARTITION_LEVEL_SUBPARTITION.
  3. When the object represents a table's subpartition templates its object type is SUBPARTITION_TEMPLATE.
  4. When the object represents a subpartition model that isn't defined by subpartition templates, its object type is SUBPARTITION.

The distinction between SUBPARTITION and SUBPARTITION_TEMPLATE is necessary to distinguish the following cases :

      subpartition by hash(<column list>) subpartitions <quantity>
      subpartition by hash(<column list>) subpartition template <quantity>
 

For consistency, all other usages that require subpartition template to be included in the DDL should set an object type of SUBPARTITION_TEMPLATE.

The following example shows how OracleTablePartitions objects are used to model a table's partitions and subpartions. The example DDL is minimal; it doesn't include any of the properties that can be used to define individual (sub)partitions:

      create table RANGE_HASH1
      ( C1 number
      , C2 number
      )
      partition by range(C1)
      subpartition by hash(C2) subpartitions 2 store as (EXAMPLE, USERS)
      ( partition P100 values less than(100)
        ( subpartition
         ,subpartition RANGE_HASH1_SP1
         ,subpartition RANGE_HASH1_SP2
        )
       ,partition P500 values less than(500)
       ,partition PMAX values less than(maxvalue)
          subpartitions 5 store in (USERS)
      )
 

An OracleTablePartitions held on a Table object is required to define the table's partitions. Its PARTITION_TYPE is RANGE and its OBJECT_TYPE is PARTITION. Its COLUMNS contains C1, and its PARTITIONS references a TablePartition object for each of P100, P500 and PMAX. The HASH_QUANTITY and HASH_QUANTITY_TABLESPACES properties aren't used as it is a range partition. Since there are subpartitions, SUBPARTITION_MODEL references another OracleTablePartitions object that defines the subpartition model. This object's PARTITION_TYPE is HASH and OBJECT_TYPE is SUBPARTITION. If instead of the clause
subpartition by hash(C2) subpartitions 2 store as (USERS)
we had
subpartition by hash(C2) subpartition template 2
the OBJECT_TYPE would be SUBPARTITION_TEMPLATE. Its would also be SUBPARTITION_TEMPLATE, if instead of defining the number of templates we specified individual templates, e.g.

      subpartition by hash(C2) subpartition template
      ( subpartition RANGE_HASH2_SP1
       ,subpartition RANGE_HASH2_SP2
      )
 

In all cases, the object's COLUMNS would contain C2 and SUBPARTITION_MODEL would be null as this object is the subpartition model (and subpartition model are only valid for RANGE PARTITIONs). In the 2 cases where the subpartition model defines the number of subpartitions, the HASH_QUANTITY property will contain that number. Additionaly, in the first case the names of the EXAMPLE and USERS tablespaces will be stored in the HASH_QUANTITY_TABLESPACES. The PARTITIONS property will be empty as individual subpartition templates aren't being defined. In contrast, when individual subpartition templates are defined, as in the example clause above, PARTITIONS will reference a TablePartition object for each of the templates (RANGE_HASH2_SP1, RANGE_HASH2_SP2).
In addition to the partitions and subpartiton model OracleTablePartitions objects, two more are required to define the partition level subpartitions of partitions P100 and PMAX. These OracleTablePartitions objects are held on the TablePartition objects that define P100 and PMAX. In both cases the PARTITION_TYPE is HASH, and OBJECT_TYPE is PARTITION_LEVEL_SUBPARTITION. COLUMNS is empty as columns cannot be specified for partition level subpartitions. For partition P100, HASH_QUANTITY, HASH_QUANTITY_TABLESPACES, and SUBPARTITION_MODEL are null or empty. Instead, PARTITIONS contains a TablePartition for each of its individual subpartitions. For partition PMAX, HASH_QUANTITY is 5 and HASH_QUANTITY_TABLESPACES contains USERS. SUBPARTITION_MODEL is null as this OracleTablePartitions object is defining partition level subpartitions, and PARTITIONS is empty because no individual sunpartitons are being defined.

DDL clauses when OBJECT_TYPE = PARTITION

  1. partition by list(COLUMNS) (PARTITIONS)
  2. partition by hash(COLUMNS) (PARTITIONS)
  3. partition by hash(COLUMNS) partitions HASH_QUANTITY [store in (HASH_QUANTITY_TABLESPACES)]
  4. partition by range(COLUMNS) [SUBPARTITION_MODEL] (PARTITIONS)

DDL clauses when OBJECT_TYPE = SUBPARTITION

  1. subpartition by list(COLUMNS)
  2. subpartition by hash(COLUMNS)
  3. subpartition by hash(COLUMNS) subpartitions HASH_QUANTITY [store in (HASH_QUANTITY_TABLESPACES)]

DDL clauses when OBJECT_TYPE = SUBPARTITION_TEMPLATE

  1. subpartition by list(COLUMNS) subpartition template (PARTITIONS)
  2. subpartition by hash(COLUMNS) subpartition template (PARTITIONS)
  3. subpartition by hash(COLUMNS) subpartition template HASH_QUANTITY

DDL clauses when OBJECT_TYPE = PARTITION_LEVEL_SUBPARTITION

  1. subpartitions HASH_QUANTITY [store in (HASH_QUANTITY_TABLESPACES)]
  2. (PARTITIONS)
Since:
11.0
See Also:
TablePartition, LOBDescriptor

Nested Class Summary
static class OracleTablePartitions.ObjectType
           
static class OracleTablePartitions.PartitionType
           

 

Nested classes/interfaces inherited from class oracle.javatools.db.AbstractDBObject
AbstractDBObject.ChildSupport

 

Field Summary
static java.lang.String KEY
           
static java.lang.String TYPE
           

 

Fields inherited from interface oracle.javatools.db.DBObject
COMMENT

 

Constructor Summary
OracleTablePartitions()
           
OracleTablePartitions(OracleTablePartitions.PartitionType partitionType, OracleTablePartitions.ObjectType objectType)
           

 

Method Summary
 void addHashQuantityTablespace(java.lang.String tablespaceName)
          Add a HASH_QUANTITY_TABLESPACE.
 void addPartition(TablePartition partition)
          Add an individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition object.
 void addPartitionColumn(DBObjectID partitionColumn)
          Add a (sub)partitioning column.
 void addPartitionColumn(DBObjectID partitionColumn, int atIndex)
          Add a (sub)partitioning column at the given index.
 TablePartition createPartition(java.lang.String name)
          Creates a TablePartition object of this.getPartitionType()+this.getObjectType and adds it to self.
 java.lang.Integer getHashQuantity()
          Return the HASH_QUANTITY.
 java.lang.String[] getHashQuantityTablespaces()
          Return an array of a HASH_QUANTITY_TABLESPACE.
 OracleTablePartitions.ObjectType getObjectType()
           
 DBObjectID[] getPartitionColumns()
          Return an array of (sub)partitioning columns.
 TablePartition[] getPartitions()
          Returns an array of individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition objects.
 OracleTablePartitions.PartitionType getPartitionType()
           
 OracleTablePartitions getSubpartitionModel()
          Returns the OracleTablePartitions object that defines the SUBPARTITION or SUBPARTITION_TEMPLATE model of a RANGE-HASH or RANGE-LIST composite partition.
 java.lang.String getType()
          Returns the type of this object.
 void removeHashQuantityTablespace(java.lang.String tablespaceName)
          Remove a HASH_QUANTITY_TABLESPACE.
 void removePartition(TablePartition partition)
          Remove an individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition object.
 void removePartitionColumn(DBObjectID partitionColumn)
          Remove a (sub)partitioning column.
 void setHashQuantity(java.lang.Integer hashQuantity)
          Set the HASH_QUANTITY.
 void setHashQuantityTablespaces(java.lang.String[] tablespaceNames)
          Replace the HASH_QUANTITY_TABLESPACE with new ones.
 void setObjectType(OracleTablePartitions.ObjectType objectType)
          Set OBJECT_TYPE as one of PARTITION, SUBPARTITION, SUBPARTITION_TEMPLATE, PARTITION_LEVEL_SUBPARTITION.
 void setPartitionColumns(DBObjectID[] partitionColumns)
          Replace the (sub)partitioning columns.
 void setPartitions(TablePartition[] partitions)
          Replace the individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition objects with new ones.
 void setPartitionType(OracleTablePartitions.PartitionType partitionType)
          Set PARTITION_TYPE as one of RANGE, HASH, LIST.
 void setSubpartitionModel(OracleTablePartitions subpartitionModel)
          Set the OracleTablePartitions object that defines the SUBPARTITION or SUBPARTITION_TEMPLATE model of a RANGE-HASH or RANGE-LIST composite partition.

 

Methods inherited from class oracle.javatools.db.AbstractChildDBObject
copyToImpl, findParent, getParent, getProperty, setParent, setProperty

 

Methods inherited from class oracle.javatools.db.AbstractDBObject
changeParent, compareToImpl, copyObject, copyTo, copyTo, copyTo, copyTo, equals, equalsImpl, findOwnedObject, findOwnedObject, findOwnedObject, getChildSupport, getID, getName, getOwnedObjects, getOwnedObjects, getOwnedObjectsImpl, getProperties, getProperty, getReferenceIDs, getReferenceIDsImpl, hashCode, includeOwnedObject, includesType, includesType, removeThisAsParent, replaceReferenceIDs, setID, setName, setProperties, toString

 

Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface oracle.javatools.db.DBObject
copyTo, copyTo, copyTo, findOwnedObject, findOwnedObject, getID, getName, getOwnedObjects, getOwnedObjects, getReferenceIDs, replaceReferenceIDs, setID, setName

 

Methods inherited from interface oracle.javatools.util.DynamicPropertySet
getProperties, getProperty, setProperties

 

Field Detail

KEY

public static final java.lang.String KEY
See Also:
Constant Field Values

TYPE

public static final java.lang.String TYPE
See Also:
Constant Field Values

Constructor Detail

OracleTablePartitions

public OracleTablePartitions()

OracleTablePartitions

public OracleTablePartitions(OracleTablePartitions.PartitionType partitionType,
                             OracleTablePartitions.ObjectType objectType)

Method Detail

getType

public java.lang.String getType()
Description copied from interface: DBObject
Returns the type of this object. Valid types include things like tables, views, synonyms, and columns.
Returns:
a string describing the type of object.

setPartitionType

public void setPartitionType(OracleTablePartitions.PartitionType partitionType)
Set PARTITION_TYPE as one of RANGE, HASH, LIST.
Parameters:
partitionType -

getPartitionType

public OracleTablePartitions.PartitionType getPartitionType()

setObjectType

public void setObjectType(OracleTablePartitions.ObjectType objectType)
Set OBJECT_TYPE as one of PARTITION, SUBPARTITION, SUBPARTITION_TEMPLATE, PARTITION_LEVEL_SUBPARTITION.
Parameters:
objectType -

getObjectType

public OracleTablePartitions.ObjectType getObjectType()

setSubpartitionModel

public void setSubpartitionModel(OracleTablePartitions subpartitionModel)
Set the OracleTablePartitions object that defines the SUBPARTITION or SUBPARTITION_TEMPLATE model of a RANGE-HASH or RANGE-LIST composite partition.
Parameters:
subpartitionModel -

getSubpartitionModel

public OracleTablePartitions getSubpartitionModel()
Returns the OracleTablePartitions object that defines the SUBPARTITION or SUBPARTITION_TEMPLATE model of a RANGE-HASH or RANGE-LIST composite partition. The individual subpartition definitions, if any, are got by calling getPartitions() on the object returned by this method.
Returns:
the OracleTablePartitions object.
See Also:
getPartitions()

setPartitionColumns

public void setPartitionColumns(DBObjectID[] partitionColumns)
Replace the (sub)partitioning columns.
  1. When the PARTITION_TYPE is LIST, one and only one column can be defined.
  2. When the PARTITION_TYPE is RANGE, there must be at least one column.
  3. When the PARTITION_TYPE is HASH, there must be between 1 and 16 columns.
  4. Columns must not be defined for a PARTITION_LEVEL_SUBPARTITION.
  5. A column must not be a ROWID or UROWID pseudocolumns.
  6. A column can be of any built-in datatype except ROWID, LONG, or LOB.
Parameters:
partitionColumns -

getPartitionColumns

public DBObjectID[] getPartitionColumns()
Return an array of (sub)partitioning columns.
Returns:

addPartitionColumn

public void addPartitionColumn(DBObjectID partitionColumn)
Add a (sub)partitioning column.
  1. When the PARTITION_TYPE is LIST, one and only one column can be defined.
  2. When the PARTITION_TYPE is RANGE, there must be at least one column.
  3. When the PARTITION_TYPE is HASH, there must be between 1 and 16 columns.
  4. Columns must not be defined for a PARTITION_LEVEL_SUBPARTITION.
  5. A column must not be a ROWID or UROWID pseudocolumns.
  6. A column can be of any built-in datatype except ROWID, LONG, or LOB.
Parameters:
partitionColumn -

addPartitionColumn

public void addPartitionColumn(DBObjectID partitionColumn,
                               int atIndex)
Add a (sub)partitioning column at the given index.
  1. When the PARTITION_TYPE is LIST, one and only one column can be defined.
  2. When the PARTITION_TYPE is RANGE, there must be at least one column.
  3. When the PARTITION_TYPE is HASH, there must be between 1 and 16 columns.
  4. Columns must not be defined for a PARTITION_LEVEL_SUBPARTITION.
  5. A column must not be a ROWID or UROWID pseudocolumns.
  6. A column can be of any built-in datatype except ROWID, LONG, or LOB.
Parameters:
partitionColumn -
atIndex -

removePartitionColumn

public void removePartitionColumn(DBObjectID partitionColumn)
Remove a (sub)partitioning column. Not valid when OBJECT_TYPE is PARTITION_LEVEL_SUBPARTITION.

setHashQuantity

public void setHashQuantity(java.lang.Integer hashQuantity)
Set the HASH_QUANTITY. Only valid when PARTITION_TYPE is HASH.
Parameters:
hashQuantity -

getHashQuantity

public java.lang.Integer getHashQuantity()
Return the HASH_QUANTITY. Only valid when PARTITION_TYPE is HASH. The value may be null.
Returns:

setHashQuantityTablespaces

public void setHashQuantityTablespaces(java.lang.String[] tablespaceNames)
Replace the HASH_QUANTITY_TABLESPACE with new ones. Only valid when PARTITION_TYPE is HASH.
Parameters:
tablespaceNames -

addHashQuantityTablespace

public void addHashQuantityTablespace(java.lang.String tablespaceName)
Add a HASH_QUANTITY_TABLESPACE. Only valid when PARTITION_TYPE is HASH.
Parameters:
tablespaceName -

removeHashQuantityTablespace

public void removeHashQuantityTablespace(java.lang.String tablespaceName)
Remove a HASH_QUANTITY_TABLESPACE. Only valid when PARTITION_TYPE is HASH.
Parameters:
tablespaceName -

getHashQuantityTablespaces

public java.lang.String[] getHashQuantityTablespaces()
Return an array of a HASH_QUANTITY_TABLESPACE. The array may be empty. Only valid when PARTITION_TYPE is HASH.
Returns:

setPartitions

public void setPartitions(TablePartition[] partitions)
Replace the individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition objects with new ones.
Parameters:
partitions -

getPartitions

public TablePartition[] getPartitions()
Returns an array of individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition objects. The array may be empty.
Returns:
an array of individual table partitions or subpartitions.

addPartition

public void addPartition(TablePartition partition)
Add an individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition object.
Parameters:
partition -

removePartition

public void removePartition(TablePartition partition)
Remove an individual PARTITION, SUBPARTITION_TEMPLATE, or PARTITION_LEVEL_SUBPARTITION TablePartition object.
Parameters:
partition -

createPartition

public TablePartition createPartition(java.lang.String name)
Creates a TablePartition object of this.getPartitionType()+this.getObjectType and adds it to self.
Parameters:
name - : name of partition or null if unnamed
Returns:
the created partition, or null if unable to create

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.2)

E13403-10


Copyright © 1997, 2013, Oracle. All rights reserved.