Enabling a table for partitioning
- Last Updated: March 30, 2020
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
Enabling a table for partitioning
The following ALTER TABLE syntax
defines the partition of a table. Here, the actual data continues
to reside in the composite initial partition and the newly added
partitions point to the composite initial partition. The data can
be accessed normally after the execution of this syntax.
Syntax
|
Parameters
- partition_definition
-
Uses the following syntax:
PARTITION BY {RANGE|LIST} column_name [PRO_DESCRIPTION desc] [subpartition_definition,...] area_spec (partition_attribute [partition_attribute ], ...)The partition_definition must contain values for all partition keys. If the partition keys are x, y, and z, then all the partition definitions must specify values for columns x, y, and z.
- subpartition_definition
-
Uses the following syntax:
SUBPARTITION BY {RANGE|LIST} column_name [PRO_DESCRIPTION desc] - column_name
-
Uses the following syntax:
simple_column_name | (simple_column_name ) - partition_attribute
-
Uses the following syntax:
PARTITION [partition_name ] VALUES { <= | IN } (column_values) [area_spec ] [ PRO_DESCRIPTION desc ]- partition_name
-
Specifies the SQL identifier.
- column_values
-
Uses the following syntax:
column_value [ , column_value, ...]- column_value
-
Uses a constant as its value. Each column_value corresponds to a column name of a partition or a subpartition, in the same order in which the column names are defined.
- area spec
-
Specifies the default areas for all partitions defined, if not overridden by specific partition definitions. The syntax for area spec is:
( ([ USING TABLE AREA area name] [ USING INDEX AREA area name] [ USING LOB AREA area name] ) | [ USING NO SPACE ])
- index_name
-
Specifies the SQL identifier. The index must be a partition aligned index.
Specifying partition specific areas on LOB columns
|
Notes
- The
ALTER TABLEstatement for table partitioning is an online operation. - Data of an unpartitioned table can be migrated to a partitioned table only if the table and all its indexes are in the type II area.
- Partition names are optional, unique across a database, and have the lexical properties of a table name; if not specified, system generated partition names are used.
- The maximum number of partitions per table is 32,767.
- A partition can be defined without any allocated data storage.
- Partition keys must be literal constants and must be enclosed
in parentheses for
LISTpartitions. ForRANGEpartitions, the parentheses are optional. - Table partitioning must be enabled for a database to use the
table partitioning syntax with the
ALTER TABLEstatement. - All index supported data types can be used as partition keys.
- The area definition at the partition level always takes priority among the area definitions provided at multiples levels.
- While migrating data from an unpartitioned table to a partitioned table,
the
ALTER TABLEstatement validates the data in the existing table based on whether the defined partitions meet the following requirements:- Only one
RANGEpartition definition is allowed per table such that the singleRANGEpartition defined has a value greater than or equal to the column's maximum value. If the table contains subpartitions, then only oneRANGEpartition is allowed per list. - Any number of
LISTpartitions can be defined as long as all the data in the column belongs to the partitions defined. For any row that does not belong to the defined partitioned, theALTER TABLEstatement returns an error.
- Only one
- For a subpartition, all the leading subpartition levels must
define
LISTpartitions. The last subpartition level can either be aRANGEpartition or aLISTpartition. - There can be up to 15 levels of subpartitioning.
- Partitioned key columns must not be repeated.
- If the partition definition has a
RANGEcolumn, then the<=clause must be used to specify the partition key values, otherwise use theINclause. - For
RANGEpartitions having the same key values, the values must be specified sequentially in an ascending order. - The following semantics apply when using the
FOR PARTITIONclause in theALTER TABLEstatement to add LOB columns:- The table specified in the statements must be a partitioned table
- The partition specified in the
FOR PARTITIONclause must be an existing partition in the table - Partitions can be specified in any order
- The specified area must be present in the table and in the type II area
- Specification of any area other than the LOB area (for example, table area) results in an error
Examples
Using ALTER TABLE with partitioned tables
The following example illustrates how to use the ALTER TABLE statement
with partitioned tables.
IDX1 and IDX2 and
an index IDX3 that is not partition aligned. |
ALTER TABLE statement
converts the above table to a partitioned table by adding one data
partition definition and specifies IDX1 as the
local composite index. IDX2 and IDX3 are
marked as global indexes. If the data in Pub.tpcustomer contains custid greater
than 100000, then the statement returns an error. |
Using ALTER TABLE with subpartitioned tables
The following example illustrates
how to use the ALTER TABLE statement with subpartitioned
tables.
Pub.sub_customer_list is LIST partitioned
by zipcode and custid. |