OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.0.0Enterprise Edition

  • Overview
    • Overview
    • System architecture
    • Compatibility with MySQL
    • Compatibility with Oracle
      • Overview
      • SQL data types
      • Built-in functions
      • System views
    • Limits
  • Get Started
    • Quick start with OceanBase Database
    • Hands on for OceanBase SQL
      • Usage notes
      • Basic SQL operations (MySQL mode)
      • Basic SQL operations (Oracle mode)
    • Build applications (MySQL Mode)
      • Connect Python applications to OceanBase Database
      • Connect Java applications to OceanBase Database
      • Connect C applications to OceanBase Database
    • Build applications(Oracle Mode)
      • Connect Python applications to OceanBase Database
      • Connect Java applications to OceanBase Database
      • Connect C applications to OceanBase Database
    • Experience OceanBase advanced features
      • Experience scalable OLTP
        • Run the TPC-C benchmark in OceanBase Database
        • Experience the hot row update capability of OceanBase Database
      • Experience operational OLAP
      • Experience parallel import and data compression
      • Experience the multitenancy feature
  • Develop
    • Develop (MySQL Mode)
      • Connect to Oceanbase Database with client
        • Overview
        • Connect to an OceanBase Database tenant by using a MySQL client
        • Connect to an OceanBase Database tenant by using OBClient
        • Connect to OceanBase Database by using ODC
        • Java application
          • OceanBase Connector/J
          • Java APIs
          • Connect Java applications to OceanBase Database
        • C application
          • OceanBase Connector/C
          • C API functions
          • Connect C applications to OceanBase Database
        • Python applications
        • SpringBoot connection example
        • SpringBatch connection example
        • Example of Database connection pool configuration
          • Overview of database connection pool configuration
          • Example of configuring a Tomcat connection pool
          • Example of configuring a C3P0 connection pool
          • Example of configuring a Proxool connection pool
          • Example of configuring a HiKariCP connection pool
          • Example of configuring a DBCP connection pool
          • CommonPool configuration example
          • Example of configuring a JDBC connection pool
        • SpringJDBC connection example
        • SpringJPA connection example
        • Hibernate connection example
        • MyBatis connection example
      • Create and manage database objects
        • About DDL statements
        • View the currently connected database
        • Change the password of a user
        • Data type
          • General data types
          • Unsupported data types
        • Create and manage tables
          • About tables
          • Create a table
          • About auto-increment columns
          • About types of column constraints
          • About table structure modification
          • About table clearing
          • About table dropping
          • Flash back a dropped table
          • About table privileges
        • Create and manage partition tables
          • About partitioned tables
          • Create a partitioned table
          • Manage a partitioned table
          • Create a subpartitioned table
          • Manage a subpartitioned table
          • Partition routing
          • Indexes on partitioned tables
          • Suggestions on using partitioned tables
        • Create and manage indexes
          • About indexes
          • Create an index
          • Drop an index
        • Create and manage views
          • About views
          • Create a view
          • Modify a view
          • Delete a view
        • Create and manage sequences
          • About sequences
          • Create a sequence
          • Modify a sequence
          • Delete a sequence
        • Create and manage triggers
          • About triggers
          • Create a trigger
          • Delete a trigger
      • Query
        • About queries
        • Single-table queries
        • Conditional queries
        • ORDER BY queries
        • GROUP BY queries
        • Use the LIMIT clause in queries
        • Query data from multiple tables
          • About multi-table join queries
          • INNER JOIN queries
          • OUTER JOIN queries
          • Subqueries
        • Use operators and functions in a query
          • Use arithmetic operators in queries
          • Use numerical functions in queries
          • Use string connectors in queries
          • Use string functions in queries
          • Use datetime functions in queries
          • Use type conversion functions in queries
          • Use aggregate functions in queries
          • Use NULL-related functions in queries
          • Use the CASE conditional operator in queries
          • Use the SELECT FOR UPDATE statement to lock query results
        • Execution plan
          • View an execution plan
          • Understand an execution plan
        • Use SQL hints in queries
        • Variables of query timeout
      • DML statements and transactions
        • DML statement
          • About DML statements
          • About the INSERT statement
          • UPDATE statements
          • About the DELETE statement
          • About the REPLACE INTO statement
        • Transactions
          • About transaction control statements
          • Start a transaction
          • Transaction savepoints
          • Commit a transaction
          • Roll back a transaction
          • About transaction timeout
      • Common errors and solutions
        • About error codes
        • Database connection error
        • About timeout
          • Idle session timeout
          • Transaction timeout errors
        • About user
          • Locked user
          • Incorrect user password
        • About table
          • Table already exists
          • Table does not exist
          • Invalid use of NULL value
        • About constraint
          • Unique key conflict
          • Foreign key conflict
        • About SQL commands
          • Data truncation
    • Develop (Oracle Mode)
      • Connect to Oceanbase Database with client
        • Overview
        • Connect to an OceanBase tenant by using an Oracle client
        • Connect to an OceanBase Database tenant by using OBClient
        • Connect to OceanBase Database by using ODC
      • Application development
        • Java application
          • OceanBase Connector/J
          • Java APIs
          • Connect Java applications to OceanBase Database
        • Python application
          • OceanBase Connector/J in Python
          • Python APIs
          • Connect Python applications to OceanBase Database
        • 300.c-application-1
          • OceanBase Connector/C
          • OBCI APIs
          • Connect C applications to OceanBase Database
      • Create and manage database objects
        • About DDL statements
        • View the currently connected database
        • Change the password of a user
        • Data type
          • General data types
          • Unsupported data types
        • Create and manage tables
          • About tables
          • Create a table
          • Define an auto-increment column by using the SEQUENCE keyword
          • About types of column constraints
          • About table structure modification
          • About table clearing
          • About table dropping
          • Flash back a dropped table
          • About table privileges
        • Create and manage partition tables
          • About partitioned tables
          • Create a partitioned table
          • Manage a partitioned table
          • Create a subpartitioned table
          • Manage a subpartitioned table
          • Partition routing
          • Indexes on partitioned tables
          • Suggestions on using partitioned tables
        • Create and manage indexes
          • Drop an index
          • About indexes
          • Create an index
        • Create and manage views
          • About views
          • Create a view
          • Modify a view
          • Drop a view
        • Create and manage sequences
          • About sequences
          • Create a sequence
          • Modify a sequence
          • Delete a sequence
        • Create and manage synonyms
          • About synonyms
          • Create a synonym
          • Delete a synonym
        • Create and manage triggers
          • About triggers
          • Create a trigger
          • Modify a trigger
          • Delete a trigger
          • Enable or disable a trigger
      • Query
        • About queries
        • Single-table queries
        • Conditional queries
        • ORDER BY queries
        • GROUP BY queries
        • Use Row_Limiting_Clause in queries
        • Query data from multiple tables
          • About multi-table join queries
          • INNER JOIN queries
          • OUTER JOIN queries
          • Subqueries
        • Use operators and functions in a query
          • Use arithmetic operators in queries
          • Use numerical functions in queries
          • Use string concatenation operators in queries
          • Use string functions in queries
          • Use datetime functions in queries
          • Use type conversion functions in queries
          • Use aggregate functions in queries
          • Use NULL-related functions in queries
          • Use CASE functions in queries
          • Use the SELECT FOR UPDATE statement to lock query results
        • Execution plan
          • View execution plans of queries
          • Understand an execution plan
        • Use SQL hints in queries
        • About query timeout variables
      • DML statements and transactions
        • DML statement
          • About DML statements
          • About the INSERT statement
          • UPDATE statements
          • About the MERGE statement
          • About the DELETE statement
        • Transactions
          • About transaction control statements
          • Start a transaction
          • Transaction savepoints
          • Commit a transaction
          • Roll back a transaction
          • About transaction timeout
      • Common errors and solutions
        • Overview
        • Database connection error
        • About timeout
          • Idle session timeout
          • Transaction timeout errors
        • About user
          • Locked user
          • Incorrect user password
        • About object
          • Object already exists
          • Object does not exist
        • About constraint
          • Unique key conflict
          • Foreign key conflict
        • About sql
          • Data type inconsistency
  • Deploy
    • Overview
    • Deployment procedure
    • Preparations before deployment
      • Prepare servers
      • Configure servers
      • Prepare installation packages
    • HA solution for OceanBase clusters
    • Deploy through the CLI
      • Configure the deployment environment
        • Install oat-cli
        • Use oat-cli to configure the deployment environment
        • Configure the clock source
        • Upload installation packages
        • Configure host information
        • Check the environment before deployment
      • Deploy OCP
        • Deployment description
        • Generate a configuration file
        • Start deployment
        • Check after deployment
      • Deploy the OceanBase cluster
        • Deploy a single-replica OceanBase cluster
        • Deploy a three-replica OceanBase cluster
      • Deploy OBProxy
        • Deploy OBProxy through the CLI
      • Create an OceanBase tenant
        • View resources available for a business tenant
        • Create a tenant
        • Verify after deployment
      • Deploy OMS
        • Deployment description
        • Modify the configuration file
        • Start deployment
        • Check after deployment
      • Deploy ODC
        • Deployment description
        • Modify the configuration file
        • Start deployment
        • Check after deployment
  • Migrate
    • Overview
    • Migrate data by using SQL scripts
    • Migrate data by using MySQLDump
    • Migrate data by using DataX
    • Migrate data by using OUTFILE statements

Download PDF

Overview System architecture Compatibility with MySQL Overview SQL data types Built-in functions System views Limits Quick start with OceanBase Database Usage notes Basic SQL operations (MySQL mode) Basic SQL operations (Oracle mode) Connect Python applications to OceanBase Database Connect Java applications to OceanBase Database Connect C applications to OceanBase Database Connect Python applications to OceanBase Database Connect Java applications to OceanBase Database Connect C applications to OceanBase Database Experience operational OLAP Experience parallel import and data compression Experience the multitenancy feature Overview Deployment procedure Prepare servers Configure servers Prepare installation packages HA solution for OceanBase clustersOverview Migrate data by using SQL scripts Migrate data by using MySQLDumpMigrate data by using DataX Migrate data by using OUTFILE statements
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Database
  3. SQL
  4. V4.0.0
iconOceanBase Database
SQL - V 4.0.0Enterprise Edition
SQL
KV
  • V 4.4.2
  • V 4.3.5
  • V 4.3.3
  • V 4.3.1
  • V 4.3.0
  • V 4.2.5
  • V 4.2.2
  • V 4.2.1
  • V 4.2.0
  • V 4.1.0
  • V 4.0.0
  • V 3.1.4 and earlier

Create a subpartitioned table

Last Updated:2023-07-24 09:52:12  Updated
share
What is on this page
Subpartitioning types
Create a subpartitioned table
SQL syntax to create a subpartitioned table by using a template
SQL syntax to create a subpartitioned table without using a template
Parameters
Examples
Create a subpartitioned table by using a template
Create a subpartitioned table without using a template

folded

share

Subpartitioning is a technique that partitions a table in two dimensions. For example, it is frequently used in scenarios that involve bills.

Subpartitioning types

OceanBase Database in Oracle mode supports the HASH, RANGE, and LIST partitioning methods, and a combination of any two of them can be used for subpartitioning. The following table describes the support for subpartitioned table creation.

Subpartitioning type Create a subpartitioned table by using a template Create a subpartitioned table without using a template
RANGE-RANGE Yes Yes
RANGE-LIST Yes Yes
RANGE-HASH Yes Yes
LIST-RANGE Yes Yes
LIST-LIST Yes Yes
LIST-HASH Yes Yes
HASH-RANGE Yes Yes
HASH-LIST Yes Yes
HASH-HASH Yes Yes

Create a subpartitioned table

When you create a subpartitioned table, you can choose whether to use a template.

SQL syntax to create a subpartitioned table by using a template

CREATE TABLE [IF NOT EXISTS] table_name(column_option_list)
  partition_option_list;

column_option_list:
  column_name column_type [, column_name column_type]

partition_option:
  PARTITION BY
    RANGE(column_name){subpartition_option} (range_partition_list)
   | LIST(expression){subpartition_option} (list_partition_list)
   | HASH(expression){subpartition_option} { (hash_partition_list)
                                             | PARTITIONS partition_count }

subpartition_option:
  SUBPARTITION BY
    RANGE(column_name) SUBPARTITION TEMPLATE(range_subpartition_list)
   | LIST(expression) SUBPARTITION TEMPLATE(list_subpartition_list)
   | HASH(expression) { SUBPARTITION TEMPLATE (hash_subpartition_list)
                       | SUBPARTITIONS subpartition_count }

range_partition_list:
  range_partition [, range_partition ...]

range_partition:
  PARTITION partition_name VALUES LESS THAN {(expression_list) | MAXVALUE}

range_subpartition_list:
  range_subpartition [, range_subpartition ...]

range_subpartition:
  SUBPARTITION subpartition_name VALUES LESS THAN {(expression_list) | MAXVALUE}

list_partition_list:
  list_partition [, list_partition ...]

list_partition:
  PARTITION partition_name VALUES {(expression_list) | DEFAULT}

list_subpartition_list:
  list_subpartition [, list_subpartition ...]

list_subpartition:
  SUBPARTITION subpartition_name VALUES {(expression_list) | DEFAULT}

hash_partition_list:
    hash_partition [, hash_partition ...]

hash_partition:
    PARTITION partition_name

hash_subpartition_list:
    hash_subpartition [, hash_subpartition ...]

hash_subpartition:
    SUBPARTITION subpartition_name

expression_list:
  expression [, expression ...]

column_name_list:
  column_name [, column_name ...]

partition_count | subpartition_count:
  INT_VALUE

Note

  • When you use a template to create a subpartitioned table, the template defines subpartitions under each partition. In this case, subpartitions under each partition share the same definition.

  • For a template-based subpartitioned table, the subpartitions are named in the format of ($part_name)s($subpart_name). For example, in the t_range_range table created by using the following statement, the partition p0 has three subpartitions: p0smp1, p0smp2, and p0smp3.

    obclient> CREATE TABLE t_range_range(col1 INT,col2 INT)
           PARTITION BY RANGE(col1)
           SUBPARTITION BY RANGE(col2)
           SUBPARTITION TEMPLATE
           (SUBPARTITION mp1 VALUES LESS THAN(100),
            SUBPARTITION mp2 VALUES LESS THAN(200),
            SUBPARTITION mp3 VALUES LESS THAN(300)
            )
           (PARTITION p0 VALUES LESS THAN(2020),
            PARTITION p1 VALUES LESS THAN(2021),
            PARTITION p2 VALUES LESS THAN(2022)
            );
    Query OK, 0 rows affected
    

SQL syntax to create a subpartitioned table without using a template

CREATE TABLE [IF NOT EXISTS] table_name(column_option_list)
  partition_option_list;

column_option_list:
  column_name column_type [, column_name column_type]

partition_option_list:
  PARTITION BY
    RANGE(column_name){subpartition_option}
      { range_partition_option (subpartition_option_list)
        [, range_partition_option (subpartition_option_list) ...]
       }
   | LIST(expression){subpartition_option}
       { list_partition_option (subpartition_option_list)
        [, list_partition_option (subpartition_option_list) ...]
        }
   | HASH(expression) {subpartition_option}
      { hash_partition_option (subpartition_option_list)
       [, hash_partition_option (subpartition_option_list) ...]
       }

subpartition_option:
  SUBPARTITION BY { RANGE(column_name) | LIST(expression) | HASH(expression) }

subpartition_option_list:
  range_partition_option_list | list_partition_option_list | hash_partition_option_list

range_partition_option_list:
  range_partition_option [, range_partition_option ...]

list_partition_option_list:
  list_partition_option [, list_partition_option ...]

hash_partition_option_list:
  hash_partition_option [, hash_partition_option ...]

range_partition_option:
  SUBPARTITION subpartition_name VALUES LESS THAN range_partition_expr
  [,SUBPARTITION subpartition_name VALUES LESS THAN range_partition_expr ...]

list_partition_option:
  SUBPARTITION subpartition_name VALUES list_partition_expr
  [, SUBPARTITION subpartition_name VALUES list_partition_expr ...]

hash_partition_option_list:
  SUBPARTITION subpartition_name
  [, SUBPARTITION subpartition_name ...]

Note

For a non-template-based subpartitioned table, you can define the subpartitioning method for each partition. You can choose whether to use the same subpartitioning method for different partitions.

Parameters

Parameter Description
table_name The table name.
column_name The column name.
column_type The data type of the column.
partition_name The partition name.
subpartition_name The subpartition name.
INT_VALUE The number of HASH or KEY subpartitions.

Examples

Create a subpartitioned table by using a template

  • Create a RANGE-RANGE-subpartitioned table by using a template.

    obclient> CREATE TABLE t2_m_rr(col1 NUMBER,col2 NUMBER)
           PARTITION BY RANGE(col1)
           SUBPARTITION BY RANGE(col2)
           SUBPARTITION TEMPLATE
             (SUBPARTITION mp0 VALUES LESS THAN(2020),
              SUBPARTITION mp1 VALUES LESS THAN(2021),
              SUBPARTITION mp2 VALUES LESS THAN(2022)
              )
             (PARTITION p0 VALUES LESS THAN(100),
              PARTITION p1 VALUES LESS THAN(200)
              );
    Query OK, 0 rows affected
    

    View the t2_m_rr subpartitioned table.

    obclient> SHOW CREATE TABLE t2_m_rr\G
    *************************** 1. row ***************************
           TABLE: T2_M_RR
    CREATE TABLE: CREATE TABLE "T2_M_RR" (
      "COL1" NUMBER(38),
      "COL2" NUMBER(38)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by range(col1) subpartition by range(col2) subpartition template (
    subpartition MP0 values less than (2020),
    subpartition MP1 values less than (2021),
    subpartition MP2 values less than (2022))
    (partition P0 values less than (100),
    partition P1 values less than (200))
    1 row in set
    

    Insert data into the t2_m_rr table.

    obclient> INSERT INTO t2_m_rr VALUES (1,1818);
    Query OK, 1 row affected
    

    View the t2_m_rr subpartitioned table.

    obclient> SELECT * FROM t2_m_rr partition(p0);
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |    1 | 1818 |
    +------+------+
    1 row in set
    
  • Create a RANGE-LIST-subpartitioned table by using a template.

    obclient> CREATE TABLE t2_m_rl(col1 NUMBER,col2 VARCHAR2(50))
           PARTITION BY RANGE(col1)
           SUBPARTITION BY LIST(col2)
           SUBPARTITION TEMPLATE
             (SUBPARTITION mp0 VALUES('01'),
              SUBPARTITION mp1 VALUES('02'),
              SUBPARTITION mp2 VALUES('03')
              )
             (PARTITION p0 VALUES LESS THAN(100),
              PARTITION p1 VALUES LESS THAN(200)
              );
    Query OK, 0 rows affected
    

    View the t2_m_rl subpartitioned table.

    obclient> SHOW CREATE TABLE t2_m_rl\G
    *************************** 1. row ***************************
           TABLE: T2_M_RL
    CREATE TABLE: CREATE TABLE "T2_M_RL" (
      "COL1" NUMBER,
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by range(col1) subpartition by list(col2) subpartition template (
    subpartition MP0 values  ('01'),
    subpartition MP1 values  ('02'),
    subpartition MP2 values  ('03'))
    (partition P0 values less than (100),
    partition P1 values less than (200))
    1 row in set
    

    Insert data into the t2_m_rl subpartitioned table.

    obclient> INSERT INTO t2_m_rl VALUES (100,'01');
    Query OK, 1 row affected
    

    View the t2_m_rl subpartitioned table.

    null
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |  100 | 01   |
    +------+------+
    1 row in set
    
  • Create a RANGE-HASH-subpartitioned table by using a template.

    obclient> CREATE TABLE t2_m_rh(col1 NUMBER,col2 VARCHAR2(50))
           PARTITION BY RANGE(col1)
           SUBPARTITION BY HASH(col2) SUBPARTITIONS 5
            (PARTITION p0 VALUES LESS THAN(100),
             PARTITION p1 VALUES LESS THAN(200)
             );
    Query OK, 0 rows affected
    

    View the t2_m_rh subpartitioned table.

    obclient>SHOW CREATE TABLE t2_m_rh\G
    *************************** 1. row ***************************
           TABLE: T2_M_RH
    CREATE TABLE: CREATE TABLE "T2_M_RH" (
      "COL1" NUMBER(38),
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by range(col1) subpartition by hash(col2) subpartition template (
    subpartition P0,
    subpartition P1,
    subpartition P2,
    subpartition P3,
    subpartition P4)
    (partition P0 values less than (100),
    partition P1 values less than (200))
    1 row in set
    

    Insert data into the t2_m_rh subpartitioned table.

    INSERT INTO t2_m_rh VALUES (100,'01');
    

    View the t2_m_rh subpartitioned table.

    obclient> SELECT * FROM t2_m_rh partition(p1);
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |  100 | 01   |
    +------+------+
    1 row in set
    
  • Create a LIST-RANGE-subpartitioned table by using a template.

    obclient> CREATE TABLE t2_m_lr(col1 NUMBER,col2 varchar2(50))
           PARTITION BY LIST(col2)
           SUBPARTITION BY RANGE(col1)
           SUBPARTITION TEMPLATE
            (SUBPARTITION mp0 VALUES LESS THAN(100),
             SUBPARTITION mp1 VALUES LESS THAN(200),
             SUBPARTITION mp2 VALUES LESS THAN(300)
             )
            (PARTITION p0 VALUES('01'),
             PARTITION p1 VALUES('02')
             );
    Query OK, 0 rows affected
    

    View the t2_m_lr subpartitioned table.

    obclient> SHOW CREATE TABLE t2_m_lr\G
    *************************** 1. row ***************************
           TABLE: T2_M_LR
    CREATE TABLE: CREATE TABLE "T2_M_LR" (
      "COL1" NUMBER(38),
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by list(col2) subpartition by range(col1) subpartition template (
    subpartition MP0 values less than (100),
    subpartition MP1 values less than (200),
    subpartition MP2 values less than (300))
    (partition P0 values  ('01'),
    partition P1 values  ('02'))
    1 row in set
    

    Insert data into the t2_m_lr subpartitioned table.

    obclient> INSERT INTO t2_m_lr VALUES (100,'01');
    Query OK, 1 row affected
    

    View the t2_m_lh subpartitioned table.

    obclient> SELECT * FROM t2_m_lr partition(p0);
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |  100 | 01   |
    +------+------+
    1 row in set
    
  • Create a LIST-LIST-subpartitioned table by using a template.

    obclient> CREATE TABLE t2_m_ll(col1 NUMBER,col2 varchar2(50))
           PARTITION BY LIST(col1)
           SUBPARTITION BY LIST(col2)
           SUBPARTITION TEMPLATE
           (SUBPARTITION mp0 VALUES('A'),
            SUBPARTITION mp1 VALUES('B'),
            SUBPARTITION mp2 VALUES('C')
            )
           (PARTITION p0 VALUES('01'),
            PARTITION p1 VALUES('02')
            );
    Query OK, 0 rows affected
    

    View the t2_m_ll subpartitioned table.

    obclient> SHOW CREATE TABLE t2_m_ll\G
    *************************** 1. row ***************************
           TABLE: T2_M_LL
    CREATE TABLE: CREATE TABLE "T2_M_LL" (
      "COL1" NUMBER,
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by list(col1) subpartition by list(col2) subpartition template (
    subpartition MP0 values  ('A'),
    subpartition MP1 values  ('B'),
    subpartition MP2 values  ('C'))
    (partition P0 values  (1),
    partition P1 values  (2))
    1 row in set
    

    Insert data into the t2_m_ll subpartitioned table.

    obclient> INSERT INTO t2_m_ll VALUES (1,'A');
    Query OK, 1 row affected
    

    View the t2_m_ll subpartitioned table.

    obclient> SELECT * FROM t2_m_ll partition(p0);
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |   1  |  A   |
    +------+------+
    1 row in set
    
  • Create a LIST-HASH-subpartitioned table by using a template.

    obclient> CREATE TABLE t2_m_lh(col1 NUMBER,col2 VARCHAR2(50))
           PARTITION BY LIST(col1)
           SUBPARTITION BY HASH(col2) SUBPARTITIONS 5
            (PARTITION p0 VALUES('01'),
             PARTITION p1 VALUES('02')
             );
    Query OK, 0 rows affected
    

    View the t2_m_lh subpartitioned table.

    obclient> SHOW CREATE TABLE t2_m_lh\G
    *************************** 1. row ***************************
           TABLE: T2_M_LH
    CREATE TABLE: CREATE TABLE "T2_M_LH" (
      "COL1" NUMBER,
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by list(col1) subpartition by hash(col2) subpartition template (
    subpartition P0,
    subpartition P1,
    subpartition P2,
    subpartition P3,
    subpartition P4)
    (partition P0 values (1),
    partition P1 values (2))
    1 row in set
    

    Insert data into the t2_m_lh subpartitioned table.

    obclient> INSERT INTO t2_m_lh VALUES (1,'A');
    Query OK, 1 row affected
    

    View the t2_m_lh subpartitioned table.

    obclient> SELECT * FROM t2_m_lh partition(p0);
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |    1 | A    |
    +------+------+
    1 row in set
    
  • Create a HASH-RANGE-subpartitioned table by using a template.

    obclient> CREATE TABLE tbl2_m_hr(col1 NUMBER,col2 NUMBER,col3 NUMBER)
           PARTITION BY HASH(col1)
           SUBPARTITION BY RANGE(col2)
           SUBPARTITION TEMPLATE
            (SUBPARTITION sp0 VALUES LESS THAN(100),
             SUBPARTITION sp1 VALUES LESS THAN(200),
             SUBPARTITION sp2 VALUES LESS THAN(300)
            )
            PARTITIONS 5;
    Query OK, 0 rows affected
    

    View the created subpartitioned table tbl2_m_hr.

    obclient> SHOW CREATE TABLE tbl2_m_hr\G
    *************************** 1. row ***************************
           TABLE: TBL2_M_HR
    CREATE TABLE: CREATE TABLE "TBL2_M_HR" (
      "COL1" NUMBER,
      "COL2" NUMBER,
      "COL3" NUMBER
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by hash(col1) subpartition by range(col2) subpartition template (
    subpartition SP0 values less than (100),
    subpartition SP1 values less than (200),
    subpartition SP2 values less than (300))
    (partition P0,
    partition P1,
    partition P2,
    partition P3,
    partition P4)
    1 row in set
    

    Insert data into the tbl2_m_hr table.

    obclient> INSERT INTO tbl2_m_hr VALUES (100,1,1);
    Query OK, 1 row affected
    

    View the tbl2_m_hr subpartitioned table.

    obclient> SELECT * FROM tbl2_m_hr partition(p1);
    +------+------+------+
    | COL1 | COL2 | COL3 |
    +------+------+------+
    |  100 |    1 |    1 |
    +------+------+------+
    1 row in set
    
  • Create a HASH-LIST-subpartitioned table by using a template.

    obclient> CREATE TABLE tbl2_m_hl(col1 NUMBER,col2 NUMBER,col3 NUMBER)
           PARTITION BY HASH(col1)
           SUBPARTITION BY LIST(col2)
           SUBPARTITION TEMPLATE
            (SUBPARTITION sp0 VALUES(100),
             SUBPARTITION sp1 VALUES(200),
             SUBPARTITION sp2 VALUES(300)
             )
            PARTITIONS 5;
    Query OK, 0 rows affected
    

    View the created subpartitioned table tbl2_m_hl.

    obclient> SHOW CREATE TABLE tbl2_m_hl\G
    *************************** 1. row ***************************
           TABLE: TBL2_M_HL
    CREATE TABLE: CREATE TABLE "TBL2_M_HL" (
      "COL1" NUMBER,
      "COL2" NUMBER,
      "COL3" NUMBER
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by hash(col1) subpartition by list(col2) subpartition template (
    subpartition SP0 values  (100),
    subpartition SP1 values  (200),
    subpartition SP2 values  (300))
    (partition P0,
    partition P1,
    partition P2,
    partition P3,
    partition P4)
    1 row in set
    

    Insert data into the tbl2_m_hl subpartitioned table.

    obclient> INSERT INTO tbl2_m_hl VALUES (100,100,100);
    Query OK, 1 row affected
    

    View the tbl2_m_hl subpartitioned table.

    obclient>  SELECT * FROM tbl2_m_hl partition(P1);
    +------+------+------+
    | COL1 | COL2 | COL3 |
    +------+------+------+
    |  100 |  100 |  100 |
    +------+------+------+
    1 row in set
    
  • Create a HASH-HASH-subpartitioned table by using a template.

    obclient> CREATE TABLE tbl2_m_hh(col1 NUMBER,col2 NUMBER,col3 NUMBER)
           PARTITION BY HASH(col1)
           SUBPARTITION BY HASH(col2)
            SUBPARTITIONS 3
            PARTITIONS 5;
    Query OK, 0 rows affected
    

    View the created subpartitioned table tbl2_m_hh.

    obclient> SHOW CREATE TABLE tbl2_m_hh\G
    *************************** 1. row ***************************
           TABLE: TBL2_M_HH
    CREATE TABLE: CREATE TABLE "TBL2_M_HH" (
      "COL1" NUMBER,
      "COL2" NUMBER,
      "COL3" NUMBER
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by hash(col1) subpartition by hash(col2) subpartition template (
    subpartition P0,
    subpartition P1,
    subpartition P2)
    (partition P0,
    partition P1,
    partition P2,
    partition P3,
    partition P4)
    1 row in set
    

    Insert data into the tbl2_m_hh table.

    obclient> INSERT INTO tbl2_m_hh VALUES (100,100,100);
    Query OK, 1 row affected
    

    View the tbl2_m_hh subpartitioned table.

    obclient> SELECT * FROM tbl2_m_hh partition(P1);
    +------+------+------+
    | COL1 | COL2 | COL3 |
    +------+------+------+
    |  100 |  100 |  100 |
    +------+------+------+
    1 row in set
    

Create a subpartitioned table without using a template

  • Create a RANGE-RANGE-subpartitioned table without using a template.

    obclient> CREATE TABLE t2_f_rr(col1 NUMBER,col2 NUMBER)
           PARTITION BY RANGE(col1)
           SUBPARTITION BY RANGE(col2)
            (PARTITION p0 VALUES LESS THAN(100)
              (SUBPARTITION sp0 VALUES LESS THAN(2020),
               SUBPARTITION sp1 VALUES LESS THAN(2021)
              ),
             PARTITION p1 VALUES LESS THAN(200)
              (SUBPARTITION sp2 VALUES LESS THAN(2020),
               SUBPARTITION sp3 VALUES LESS THAN(2021),
               SUBPARTITION sp4 VALUES LESS THAN(2022)
               )
             );
    Query OK, 0 rows affected
    

    View the t2_f_rr subpartitioned table.

    obclient>  SHOW CREATE TABLE t2_f_rr\G
    *************************** 1. row ***************************
           TABLE: T2_F_RR
    CREATE TABLE: CREATE TABLE "T2_F_RR" (
      "COL1" NUMBER,
      "COL2" NUMBER
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by range(col1) subpartition by range(col2)
    (partition P0 values less than (100) (
    subpartition SP0 values less than (2020),
    subpartition SP1 values less than (2021)),
    partition P1 values less than (200) (
    subpartition SP2 values less than (2020),
    subpartition SP3 values less than (2021),
    subpartition SP4 values less than (2022)))
    1 row in set
    

    Insert data into the t2_f_rr table.

    obclient> INSERT INTO t2_f_rr VALUES (100,100);
    Query OK, 1 row affected
    

    View the t2_f_rr subpartitioned table.

    obclient> SELECT * FROM t2_f_rr partition(P1);
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |  100 |  100 |
    +------+------+
    1 row in set
    
  • Create a RANGE-LIST-subpartitioned table without using a template.

    obclient> CREATE TABLE t2_f_rl(col1 NUMBER,col2 VARCHAR2(50))
           PARTITION BY RANGE(col1)
           SUBPARTITION BY LIST(col2)
           (PARTITION p0 VALUES LESS THAN(100)
             (SUBPARTITION sp0 VALUES('01'),
              SUBPARTITION sp1 VALUES('02')
              ),
            PARTITION p1 VALUES LESS THAN(200)
             (SUBPARTITION sp2 VALUES('01'),
              SUBPARTITION sp3 VALUES('02'),
              SUBPARTITION sp4 VALUES('03')
             )
            );
    Query OK, 0 rows affected
    

    View the t2_f_rl subpartitioned table.

    obclient> SHOW CREATE TABLE t2_f_rl\G
    *************************** 1. row ***************************
           TABLE: T2_F_RL
    CREATE TABLE: CREATE TABLE "T2_F_RL" (
      "COL1" NUMBER,
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by range(col1) subpartition by list(col2)
    (partition P0 values less than (100) (
    subpartition SP0 values  ('01'),
    subpartition SP1 values  ('02')),
    partition P1 values less than (200) (
    subpartition SP2 values  ('01'),
    subpartition SP3 values  ('02'),
    subpartition SP4 values  ('03')))
    1 row in set
    

    Insert data into the t2_f_rl subpartitioned table.

    obclient> INSERT INTO t2_f_rl VALUES (99,'01'),(99,'02'),(199,'01'),(199,'02');
    Query OK, 2 rows affected
    Records: 2  Duplicates: 0  Warnings: 0
    

    View the t2_f_rl subpartitioned table.

    obclient> SELECT * FROM t2_f_rl;
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |   99 | 01   |
    |   99 | 02   |
    |  199 | 01   |
    |  199 | 02   |
    +------+------+
    4 rows in set
    
  • Create a non-template-based RANGE-HASH-subpartitioned table.

    obclient> CREATE TABLE t2_f_rh(col1 NUMBER,col2 VARCHAR2(50))
           PARTITION BY RANGE(col1)
           SUBPARTITION BY HASH(col2)
           (PARTITION p0 VALUES LESS THAN(100)
             (SUBPARTITION sp0,
              SUBPARTITION sp1
              ),
            PARTITION p1 VALUES LESS THAN(200)
             (SUBPARTITION sp2,
              SUBPARTITION sp3,
              SUBPARTITION sp4
              )
            );
    Query OK, 0 rows affected
    

    View the t2_f_rh subpartitioned table.

    obclient> SHOW CREATE TABLE t2_f_rh\G
    *************************** 1. row ***************************
           TABLE: T2_F_RH
    CREATE TABLE: CREATE TABLE "T2_F_RH" (
      "COL1" NUMBER,
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by range(col1) subpartition by hash(col2)
    (partition P0 values less than (100) (
    subpartition SP0,
    subpartition SP1),
    partition P1 values less than (200) (
    subpartition SP2,
    subpartition SP3,
    subpartition SP4))
    1 row in set
    

    Insert data into the t2_f_rh subpartitioned table.

    obclient> INSERT INTO t2_f_rh VALUES (199,'02'),(299,'02');
    Query OK, 2 rows affected
    Records: 2  Duplicates: 0  Warnings: 0
    

    View the t2_f_rh subpartitioned table.

    obclient> SELECT * FROM t2_f_rh;
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |  199 | 02   |
    |  299 | 02   |
    +------+------+
    2 rows in set
    
  • Create a LIST-RANGE-subpartitioned table without using a template.

    obclient> CREATE TABLE t2_f_lr(col1 INT,col2 VARCHAR2(50))
           PARTITION BY LIST(col2)
           SUBPARTITION BY RANGE(col1)
           (PARTITION p0 VALUES('01')
             (SUBPARTITION sp0 VALUES LESS THAN(100),
              SUBPARTITION sp1 VALUES LESS THAN(200)
              ),
            PARTITION p1 VALUES('02')
             (SUBPARTITION sp2 VALUES LESS THAN(100),
              SUBPARTITION sp3 VALUES LESS THAN(200),
              SUBPARTITION sp4 VALUES LESS THAN(300)
              )
            );
    Query OK, 0 rows affected
    

    View the t2_f_lr subpartitioned table.

    obclient> SHOW CREATE TABLE t2_f_lr\G
    *************************** 1. row ***************************
           TABLE: T2_F_LR
    CREATE TABLE: CREATE TABLE "T2_F_LR" (
      "COL1" NUMBER(38),
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by list(col2) subpartition by range(col1)
    (partition P0 values  ('01') (
    subpartition SP0 values less than (100),
    subpartition SP1 values less than (200)),
    partition P1 values  ('02') (
    subpartition SP2 values less than (100),
    subpartition SP3 values less than (200),
    subpartition SP4 values less than (300)))
    1 row in set
    

    Insert data into the t2_f_lr subpartitioned table.

    obclient> INSERT INTO t2_f_lr VALUES (199,'02'),(299,'02');
    Query OK, 1 row affected
    

    View the t2_f_lr subpartitioned table.

    obclient> SELECT * FROM t2_f_lr;
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |  199 | 02   |
    |  299 | 02   |
    +------+------+
    2 rows in set
    
  • Create a LIST-LIST-subpartitioned table without using a template.

    obclient> CREATE TABLE t2_f_ll(col1 NUMBER,col2 varchar2(50))
           PARTITION BY LIST(col1)
           SUBPARTITION BY LIST(col2)
           (PARTITION p0 VALUES ('01', '02')
             (SUBPARTITION sp0 VALUES ('A'),
              SUBPARTITION sp1 VALUES ('B'),
              SUBPARTITION sp2 VALUES ('C')
              ),
            PARTITION p1 VALUES ('03', '04')
             (SUBPARTITION sp3 VALUES ('A'),
              SUBPARTITION sp4 VALUES ('B'),
              SUBPARTITION sp5 VALUES ('C')
              )
            );
    Query OK, 0 rows affected
    

    View the t2_f_ll subpartitioned table.

    obclient> SHOW CREATE TABLE t2_f_ll\G
    *************************** 1. row ***************************
           TABLE: T2_F_LL
    CREATE TABLE: CREATE TABLE "T2_F_LL" (
      "COL1" NUMBER,
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by list(col1) subpartition by list(col2)
    (partition P0 values  (1,2) (
    subpartition SP0 values  ('A'),
    subpartition SP1 values  ('B'),
    subpartition SP2 values  ('C')),
    partition P1 values  (3,4) (
    subpartition SP3 values  ('A'),
    subpartition SP4 values  ('B'),
    subpartition SP5 values  ('C')))
    1 row in set
    

    Insert data into the t2_f_ll subpartitioned table.

    obclient> INSERT INTO t2_f_ll VALUES (1,'A');
    Query OK, 1 row affected
    

    View the t2_f_ll subpartitioned table.

    obclient> SELECT * FROM t2_f_ll;
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |    1 | A    |
    +------+------+
    1 row in set
    
  • Create a LIST-HASH-subpartitioned table without using a template.

    obclient> CREATE TABLE t2_f_lh(col1 NUMBER,col2 VARCHAR2(50))
           PARTITION BY LIST(col1)
           SUBPARTITION BY HASH(col2)
           (PARTITION p0 VALUES('01')
             (SUBPARTITION sp0,
              SUBPARTITION sp1
              ),
            PARTITION p1 VALUES('02')
             (SUBPARTITION sp2,
              SUBPARTITION sp3,
              SUBPARTITION sp4
              )
            );
    Query OK, 0 rows affected
    

    View the t2_f_lh subpartitioned table.

    obclient> SHOW CREATE TABLE t2_f_lh\G
    *************************** 1. row ***************************
           TABLE: T2_F_LH
    CREATE TABLE: CREATE TABLE "T2_F_LH" (
      "COL1" NUMBER,
      "COL2" VARCHAR2(50)
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by list(col1) subpartition by hash(col2)
    (partition P0 values  (1) (
    subpartition SP0,
    subpartition SP1),
    partition P1 values  (2) (
    subpartition SP2,
    subpartition SP3,
    subpartition SP4))
    1 row in set
    

    Insert data into the t2_f_lh subpartitioned table.

    obclient> INSERT INTO t2_f_lh VALUES (1,'A');
    Query OK, 1 row affected
    

    View the t2_f_lh subpartitioned table.

    obclient> SELECT * FROM t2_f_lh;
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |    1 | A    |
    +------+------+
    1 row in set
    
  • Create a HASH-RANGE-subpartitioned table without using a template.

    obclient> CREATE TABLE tbl2_f_hr(col1 NUMBER,col2 NUMBER,col3 NUMBER)
           PARTITION BY HASH(col1)
           SUBPARTITION BY RANGE(col2)
            (PARTITION p0
             (SUBPARTITION sp0 VALUES LESS THAN(100),
              SUBPARTITION sp1 VALUES LESS THAN(200)),
            PARTITION p1
             (SUBPARTITION sp2 VALUES LESS THAN(100),
              SUBPARTITION sp3 VALUES LESS THAN(200)
             )
            );
    Query OK, 0 rows affected
    

    View the tbl2_f_hr subpartitioned table.

    obclient> SHOW CREATE TABLE tbl2_f_hr\G
    *************************** 1. row ***************************
           TABLE: TBL2_F_HR
    CREATE TABLE: CREATE TABLE "TBL2_F_HR" (
      "COL1" NUMBER,
      "COL2" NUMBER,
      "COL3" NUMBER
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by hash(col1) subpartition by range(col2)
    (partition P0 (
    subpartition SP0 values less than (100),
    subpartition SP1 values less than (200)),
    partition P1 (
    subpartition SP2 values less than (100),
    subpartition SP3 values less than (200)))
    1 row in set
    

    Insert data into the tbl2_f_hr subpartitioned table.

    obclient> INSERT INTO tbl2_f_hr VALUES (1,1,1);
    Query OK, 1 row affected
    

    View the tbl2_f_hr subpartitioned table.

    obclient> SELECT * FROM tbl2_f_hr;
    +------+------+------+
    | COL1 | COL2 | COL3 |
    +------+------+------+
    |    1 |    1 |    1 |
    +------+------+------+
    1 row in set
    
  • Create a HASH-LIST-subpartitioned table without using a template.

    obclient> CREATE TABLE t2_f_hl(col1 NUMBER,col2 NUMBER,col3 NUMBER)
           PARTITION BY HASH(col1)
           SUBPARTITION BY LIST(col2)
            (PARTITION p0
              (SUBPARTITION sp0 VALUES(1,3),
               SUBPARTITION sp1 VALUES(4,7)
              ),
             PARTITION p1
              (SUBPARTITION sp2 VALUES(1,3),
               SUBPARTITION sp3 VALUES(4,7)
               )
            );
    Query OK, 0 rows affected
    

    View the created subpartitioned table t2_f_hl.

    obclient> SHOW CREATE TABLE t2_f_hl\G
    *************************** 1. row ***************************
           TABLE: T2_F_HL
    CREATE TABLE: CREATE TABLE "T2_F_HL" (
      "COL1" NUMBER,
      "COL2" NUMBER,
      "COL3" NUMBER
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by hash(col1) subpartition by list(col2)
    (partition P0 (
    subpartition SP0 values (1,3),
    subpartition SP1 values (4,7)),
    partition P1 (
    subpartition SP2 values (1,3),
    subpartition SP3 values (4,7)))
    1 row in set
    

    Insert data into the t2_f_hl table.

    obclient> INSERT INTO t2_f_hl VALUES (199,1,1);
    Query OK, 1 row affected
    

    View the t2_f_hl subpartitioned table.

    obclient> SELECT * FROM t2_f_hl;
    +------+------+------+
    | COL1 | COL2 | COL3 |
    +------+------+------+
    |  199 |    1 |    1 |
    +------+------+------+
    1 row in set
    
  • Create a HASH-HASH-subpartitioned table without using a template.

    obclient> CREATE TABLE t2_f_hh(col1 NUMBER,col2 NUMBER,col3 NUMBER)
           PARTITION BY HASH(col1)
           SUBPARTITION BY HASH(col2)
            (PARTITION p0
              (SUBPARTITION sp0,
               SUBPARTITION sp1
               ),
             PARTITION p1
              (SUBPARTITION sp2,
               SUBPARTITION sp3
               )
            );
    Query OK, 0 rows affected
    

    View the t2_f_hh subpartitioned table.

    obclient> SHOW CREATE TABLE t2_f_hh\G
    *************************** 1. row ***************************
           TABLE: T2_F_HH
    CREATE TABLE: CREATE TABLE "T2_F_HH" (
      "COL1" NUMBER,
      "COL2" NUMBER,
      "COL3" NUMBER
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
     partition by hash(col1) subpartition by hash(col2)
    (partition P0 (
    subpartition SP0,
    subpartition SP1),
    partition P1 (
    subpartition SP2,
    subpartition SP3))
    1 row in set
    

    Insert data into the t2_f_hh subpartitioned table.

    obclient> INSERT INTO t2_f_hh VALUES (199,1,1);
    Query OK, 1 row affected
    

    View the t2_f_hh subpartitioned table.

    obclient> SELECT * FROM t2_f_hh;
    +------+------+------+
    | COL1 | COL2 | COL3 |
    +------+------+------+
    |  199 |    1 |    1 |
    +------+------+------+
    1 row in set
    

Previous topic

Manage a partitioned table
Last

Next topic

Manage a subpartitioned table
Next
What is on this page
Subpartitioning types
Create a subpartitioned table
SQL syntax to create a subpartitioned table by using a template
SQL syntax to create a subpartitioned table without using a template
Parameters
Examples
Create a subpartitioned table by using a template
Create a subpartitioned table without using a template