Help Center/ Data Lake Insight/ Spark SQL Syntax Reference/ Tables/ Viewing a Table/ Viewing All Partitions in a Specified Table
Updated on 2024-07-04 GMT+08:00

Viewing All Partitions in a Specified Table

Function

This statement is used to check all partitions in a specified table.

Syntax

1
2
SHOW PARTITIONS [db_name.]table_name
  [PARTITION partition_specs];

Keywords

  • PARTITIONS: partitions in a specified table
  • PARTITION: a specified partition

Parameters

Table 1 Parameters

Parameter

Description

db_name

Database name that contains letters, digits, and underscores (_). It cannot contain only digits and cannot start with an underscore (_).

table_name

Table name of a database that contains letters, digits, and underscores (_). The name cannot contain only digits or start with an underscore (_).

The matching rule is ^(?!_)(?![0-9]+$)[A-Za-z0-9_$]*$. If special characters are required, use single quotation marks ('') to enclose them.

partition_specs

Partition information, in the format of "key=value", where key indicates the partition field and value indicates the partition value. If a partition field contains multiple fields, the system displays all partition information that matches the partition field.

Precautions

The table specified in this statement must exist and must be a partitioned table. Otherwise, an error is reported.

Example

  • To show all partitions in the student table, run the following statement:
    1
    SHOW PARTITIONS student;
    
  • Check the dt='2010-10-10' partition in the student table, run the following statement:
    1
    SHOW PARTITIONS student PARTITION(dt='2010-10-10');