分享方式:


顯示數據分割

適用於: 檢查標示為是 Databricks SQL 檢查標示為是 Databricks Runtime

列出數據表的數據分割。

語法

SHOW PARTITIONS table_name [ PARTITION clause ]

參數

  • table_name

    識別數據表。 名稱不得包含 時態規格

  • PARTITION 子句

    指定數據分割的選擇性參數。 如果規格只是部分傳回所有相符的數據分割。 如果未在所有 Databricks SQL 指定任何數據分割,則會傳回所有分割區。

範例

-- create a partitioned table and insert a few rows.
> USE salesdb;
> CREATE TABLE customer(id INT, name STRING) PARTITIONED BY (state STRING, city STRING);
> INSERT INTO customer PARTITION (state = 'CA', city = 'Fremont') VALUES (100, 'John');
> INSERT INTO customer PARTITION (state = 'CA', city = 'San Jose') VALUES (200, 'Marry');
> INSERT INTO customer PARTITION (state = 'AZ', city = 'Peoria') VALUES (300, 'Daniel');

-- Lists all partitions for table `customer`
> SHOW PARTITIONS customer;
   state=AZ/city=Peoria
  state=CA/city=Fremont
 state=CA/city=San Jose

-- Lists all partitions for the qualified table `customer`
> SHOW PARTITIONS salesdb.customer;
   state=AZ/city=Peoria
  state=CA/city=Fremont
 state=CA/city=San Jose

-- Specify a full partition spec to list specific partition
> SHOW PARTITIONS customer PARTITION (state = 'CA', city = 'Fremont');
 |state=CA/city=Fremont|

-- Specify a partial partition spec to list the specific partitions
> SHOW PARTITIONS customer PARTITION (state = 'CA');
  state=CA/city=Fremont
 state=CA/city=San Jose

-- Specify a partial spec to list specific partition
> SHOW PARTITIONS customer PARTITION (city =  'San Jose');
 state=CA/city=San Jose