هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Automatic Partitioning of Level-2 Partitioned Tables

Updated on 2024-06-07 GMT+08:00

When creating a level-2 partitioned table, you can specify the AUTOMATIC keyword in the list partition definition to support automatic level-1 and level-2 partitioning of the level-2 partitioned table. Automatic extension of level-2 list partitioned tables supports only single-column partition keys.

  • When creating a level-2 partitioned table, specify AUTOMATIC in the level-1 partition definition to support automatic level-1 partitioning.
    gaussdb=# CREATE TABLE autolist_range (c1 int, c2 int)
    PARTITION BY LIST (c1) AUTOMATIC SUBPARTITION BY RANGE (c2)
    (
        PARTITION p1 VALUES (1, 2, 3) (
            SUBPARTITION sp11 VALUES LESS THAN (5),
            SUBPARTITION sp12 VALUES LESS THAN (10)
        ),
        PARTITION p2 VALUES (4, 5, 6) (
            SUBPARTITION sp21 VALUES LESS THAN (5),
            SUBPARTITION sp22 VALUES LESS THAN (10)
        )
    );
    If the inserted data cannot match any existing level-1 partition, a level-1 partition is automatically created. The range of the new level-1 partition is defined as a single key (new partition key corresponding to the new data), and a level-2 partition is defined under the new level-1 partition.
    -- Insert data 9 into the level-1 partition key. Because the key values of the existing level-1 partitions p1 and p2 do not contain 9, a level-1 partition sys_p1 is automatically created and the partition is defined as VALUES (9).
    gaussdb=# INSERT INTO autolist_range VALUES (9, 0);

    This function is equivalent to the following commands:

    gaussdb=# ALTER TABLE autolist_range ADD PARTITION sys_p1 VALUES (9); 
    gaussdb=# INSERT INTO autolist_range VALUES (9, 0);
    gaussdb=# DROP TABLE autolist_range;
  • When creating a level-2 partitioned table, specify AUTOMATIC in the level-2 partition definition to support automatic level-2 partitioning.
    gaussdb=# CREATE TABLE range_autolist (c1 int, c2 int)
    PARTITION BY RANGE (c1) SUBPARTITION BY LIST (c2) AUTOMATIC
    (
        PARTITION p1 VALUES LESS THAN (5) (
            SUBPARTITION sp11 VALUES (1, 2, 3),
            SUBPARTITION sp12 VALUES (4, 5, 6)
        ),
        PARTITION p2 VALUES LESS THAN (10) (
            SUBPARTITION sp21 VALUES (1, 2, 3),
            SUBPARTITION sp22 VALUES (4, 5, 6)
        )
    );

    If the inserted data cannot match any existing level-2 partition, a level-2 partition is automatically created under the corresponding level-1 partition. The range of the new level-2 partition is defined as a single key (new partition key value corresponding to the new data).

    -- Insert data 0 into the level-2 partition key. Because the key value of the existing level-2 partition does not contain 0, a level-2 partition sys_sp1 is automatically created. The partition is defined as VALUES (0).
    gaussdb=# INSERT INTO range_autolist VALUES (4, 0);

    This function is equivalent to the following commands:

    gaussdb=# ALTER TABLE range_autolist MODIFY PARTITION p1 ADD SUBPARTITION sys_sp1 VALUES (0); 
    gaussdb=# INSERT INTO range_autolist VALUES (4, 0);
    
    -- Cleanup example
    gaussdb=# DROP TABLE range_autolist;
  • When creating a level-2 partitioned table, specify AUTOMATIC in both level-1 and level-2 partition definitions to support automatic level-1 and level-2 partitioning.
    gaussdb=# CREATE TABLE autolist_autolist (c1 int, c2 int)
    PARTITION BY LIST (c1) AUTOMATIC SUBPARTITION BY LIST (c2) AUTOMATIC
    (
        PARTITION p1 VALUES (1, 2, 3) (
            SUBPARTITION sp11 VALUES (1, 2, 3),
            SUBPARTITION sp12 VALUES (4, 5, 6)
        ),
        PARTITION p2 VALUES (4, 5, 6) (
            SUBPARTITION sp21 VALUES (1, 2, 3),
            SUBPARTITION sp22 VALUES (4, 5, 6)
        )
    );
    • If the inserted data cannot match any existing level-1 partition, a level-1 partition is automatically created. The range of the new level-1 partition is defined as a single key (new partition key corresponding to the new data), and a level-2 partition with a single key is defined.
      -- Insert data 9 into the level-1 partition key. Because the key values of the existing level-1 partitions p1 and p2 do not contain 9, a level-1 partition sys_p1 is automatically created and the partition is defined as VALUES (9). At the same time, data 0 is inserted into the level-2 partition key. Because the key value of the existing level-2 partition does not contain 0, a level-2 partition sys_sp1 is defined in the new level-1 partition sys_p1. The partition is defined as VALUES (0).
      gaussdb=# INSERT INTO autolist_autolist VALUES (9, 0);

      This function is equivalent to the following commands:

      gaussdb=# ALTER TABLE autolist_autolist ADD PARTITION sys_p1 VALUES (9) (SUBPARTITION sys_sp1 VALUES (0)); 
      gaussdb=# INSERT INTO autolist_autolist VALUES (9, 0);
    • If the inserted data cannot match any existing level-2 partition, a level-2 partition is automatically created under the corresponding level-1 partition. The range of the new level-2 partition is defined as a single key (new partition key value corresponding to the new data).
      -- Insert data 0 into the level-2 partition key. Because the key value of the existing level-2 partition does not contain 0, a level-2 partition sys_sp2 is automatically created and the partition is defined as VALUES (0).
      gaussdb=# INSERT INTO autolist_autolist VALUES (4, 0);

      This function is equivalent to the following commands:

      gaussdb=# ALTER TABLE autolist_autolist MODIFY PARTITION p2 ADD SUBPARTITION sys_sp2 VALUES (0); 
      gaussdb=# INSERT INTO autolist_autolist VALUES (4, 0);
      
      -- Cleanup example
      gaussdb=# DROP TABLE autolist_autolist;
NOTE:

The position specifying the AUTOMATIC keyword affects automatic list partitioning of level-2 partitioned tables as follows:

  • If the AUTOMATIC keyword is specified after a level-1 partition, only automatic level-1 partitioning is supported. No level-2 partition can be automatically created, and no DEFAULT level-1 partition key is allowed.
  • If the AUTOMATIC keyword is specified after a level-2 partition, only automatic level-2 partitioning is supported. No level-1 partition can be automatically created, and no DEFAULT level-2 partition key is allowed.
  • If the AUTOMATIC keyword is specified after both the level-1 and level-2 partitions, automatic level-1 and level-2 partitioning is supported. No DEFAULT level-1 and level-2 partition keys are allowed.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback