Overview¶
Partitioning refers to splitting what is logically one large table into smaller physical pieces based on specific schemes. The table based on the logic is called a partitioned table, and a physical piece is called a partition. Data is stored on these smaller physical pieces, namely, partitions, instead of the larger logical partitioned table.
Follow the steps below to define a table in your database:
In the Object Browser pane, right-click Regular Tables, and choose Create Partition Table.
Define basic table information, such as the table name and table type. For details, see Providing Basic Information.
Define column information, such as the column name, data type schema, data type, and column constraint. For details, see Defining a Column.
Select the data distribution information for the table. For details, see Change Order of Partition.
Define column constraints for different constraint types. Constraint types include PRIMARY KEY, UNIQUE, and CHECK. For details, see Defining Table Constraints.
Define table index information, such as the index name and access mode. For details, see Defining an Index.
Define the partition information for the table such as partition name, partition column, partition value and so on. For details, see Defining a Partition.
On the SQL Preview tab, you can check the automatically generated SQL query. For details, see Checking the SQL Preview.
To add comments to Column in the Create Partition Table dialog box, add column information in Description of Column (Max 5000 chars) text box and click Add.
Providing Basic Information¶
Provide the following information to create a table:
For details, see Providing Basic Information.
Table Name
Schema
Options
Description of Table
Perform the following steps to configure other parameters:
Select a table storage mode from the Table Orientation drop-down list.
Note
If table orientation is selected as ORC, then an HDFS Partitioned table is created.
Enter the ORC version number in the ORC Version field. This is applicable only for HDFS Partitioned table.
After providing the general information about the table, click Next to define the columns information for the table.
The following table describes the parameters of partitioned tables.
¶ Parameter
Row Partition
Column Partition
ORC Partition
Table Type
x
x
x
If Not Exists
Y
Y
Y
With OIDS
x
x
x
Fill Factor
Y
x
x
Defining a Column¶
For details, see Defining a Column.
The following table describes the parameters of partitioned tables.
Field | Row Partition | Column Partition | ORC Partition |
---|---|---|---|
Array Dimensions | Y | x | x |
Data Type | Y | x | x |
NOT NULL | Y | Y | Y |
Default | Y | Y | Y |
UNIQUE | Y | x | x |
CHECK | Y | x | x |
Change Order of Partition¶
You can change the order of partition as required in the table. To change the order, select the required partition and click Up or Down.
Checking the SQL Preview¶
For details, see SQL Preview.
Editing a Partition¶
Perform the following steps to edit a partition:
Select a partition.
Click Edit.
Edit partition configurations as needed and click Update to save the changes.
Note
You must complete the edit operation and save the changes to continue with other operations.
Deleting a Partition¶
Perform the following steps to delete a partition:
Select a partition.
Click Delete.
Defining a Partition¶
The following table describes the parameters of partitioned tables.
Parameter | Row Partition | Column Partition | ORC Partition |
---|---|---|---|
Partition Type | By Range | By Range | By Value |
Partition Name | Y | Y | x |
Partition Value | Y | Y | x |
Perform the following steps to define a table partition:
If Row or Column is selected for Table Orientation on the General tab, By Range will be displayed in the Partition Type area. If ORC is selected for Table Orientation on the General tab, By Value will be displayed in the Partition Type area.
In the Available Column area, select a column and click .
The column will be moved to the Partition Column area.
Note
If Table Orientation is set to Row or Column, only one column can be selected for partitioning.
If Table Orientation is set to ORC, up to four columns can be selected for partitioning.
A maximum of four columns can be selected to define partitions.
Enter a partition name.
Click next to Partition Value.
Enter the value by which you want to partition the table in Value column.
Click OK.
After you enter all information for partition, click Add.
After defining all partitions, click Next.
You can perform the following operations on the partitions of a row-or column-partitioned table, but not on ORC partitioned tables:
Defining an Index¶
For details about index definitions, see Defining an Index.
Parameter | Row Partition | Column Partition | ORC Partition |
---|---|---|---|
Unique Indexes | Y | x | x |
btree | Y | Y | x |
gin | Y | Y | x |
gist | Y | Y | x |
hash | Y | Y | x |
psort | Y | Y | x |
spgist | Y | Y | x |
Fill Factor | Y | x | x |
User Defined Expression | Y | x | x |
Partial Index | Y | x | x |
Defining Table Constraints¶
For details about how to define table constraints, see Defining Table Constraints.
Parameter | Partition | Column Partition | ORC Partition |
---|---|---|---|
Check | Y | x | x |
Unique | Y | x | x |
Primary Key | Y | x | x |
Configuring Data Distribution¶
For details about how to select a distribution type, see Selecting Data Distribution.
Parameter | Row Partition | Column Partition | ORC Partition |
---|---|---|---|
DEFAULT DISTRIBUTION | Y | Y | x |
Hash | Y | Y | Y |
Replication | Y | Y | x |