Show All Partitions of Specified Table
Function
View all partitions of a specified table. Use the PARTITION clause to specify partition conditions for filtering. Partial partition key matching is supported.
Syntax
SHOW PARTITIONS [ db_name. ] table_name [ PARTITION partition_specs ]
The syntax for partition_specs is:
partition_specs = ( partition_col_name = partition_col_value [ , partition_col_name = partition_col_value , ... ] )
Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| db_name | No | Database name. If not specified, the current database is used by default. Naming rule: Only letters, digits, and underscores (_) are allowed. Cannot be purely numeric and cannot start with an underscore. |
| table_name | Yes | Table name. The table being viewed must be a partitioned table. Otherwise, an error will occur. Naming rule: Only letters, digits, and underscores (_) are allowed. Cannot be purely numeric and cannot start with an underscore. The matching rule is ^(?!_)(?![0-9]+$)[A-Za-z0-9_$]*$. If it contains special characters, it must be enclosed in backticks (``). |
| PARTITION partition_specs | No | Partition filter condition, in the format of key=value. If the partition has multiple fields, not all fields need to be included. The system will return all matching partition information. |
Precautions
- The table whose partitions are to be viewed must exist and be a partitioned table. Otherwise, an error will occur.
- In partition_specs, only some partition keys can be specified. The system will return all matching partitions. For example, for a three-level partitioned table (year, month, day), specifying only year=2024 will return all partitions under that year.
Example 1: View All Partitions of a Table
View all partitions under the student table.
SHOW PARTITIONS student;
Example result:
+-------------------+ |partition | +-------------------+ |year=2024/month=01 | |year=2024/month=02 | |year=2024/month=03 | +-------------------+
Example 2: View a Specific Partition
View the partition in the student table where year=2024 and month=01.
SHOW PARTITIONS student PARTITION(year='2024', month='01');
Example 3: Partial Partition Key Matching
View all partitions in the student table where year=2024 (without specifying month, all monthly partitions under that year will be returned).
SHOW PARTITIONS student PARTITION(year='2024');
Example result:
+-------------------+ |partition | +-------------------+ |year=2024/month=01 | |year=2024/month=02 | |year=2024/month=03 | +-------------------+
Example 4: View Partitions of a Table in a Specified Database
View all partitions of the student table in the school_db database.
SHOW PARTITIONS school_db.student;
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot