SHOW PARTITIONS
說明
SHOW PARTITIONS
陳述式用於列出資料表的分割區。可以指定選用分割區規格,以傳回符合所提供分割區規格的分割區。
語法
SHOW PARTITIONS table_identifier [ partition_spec ]
參數
-
table_identifier
指定資料表名稱,可以選擇使用資料庫名稱限定。
語法:
[ database_name. ] table_name
-
partition_spec
選用參數,指定分割區的逗號分隔清單,其中包含金鑰和值對。指定時,傳回符合分割區規格的分割區。
語法:
PARTITION ( partition_col_name = partition_col_val [ , ... ] )
範例
-- 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;
+----------------------+
| partition|
+----------------------+
| 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;
+----------------------+
| partition|
+----------------------+
| 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');
+---------------------+
| partition|
+---------------------+
|state=CA/city=Fremont|
+---------------------+
-- Specify a partial partition spec to list the specific partitions
SHOW PARTITIONS customer PARTITION (state = 'CA');
+----------------------+
| partition|
+----------------------+
| state=CA/city=Fremont|
|state=CA/city=San Jose|
+----------------------+
-- Specify a partial spec to list specific partition
SHOW PARTITIONS customer PARTITION (city = 'San Jose');
+----------------------+
| partition|
+----------------------+
|state=CA/city=San Jose|
+----------------------+