SHOW PARTITIONS

    • table_identifier

      Syntax: [ database_name. ] table_name

    • An optional parameter that specifies a comma separated list of key and value pairs for partitions. When specified, the partitions that match the partition specification are returned.

    1. -- create a partitioned table and insert a few rows.
    2. USE salesdb;
    3. CREATE TABLE customer(id INT, name STRING) PARTITIONED BY (state STRING, city STRING);
    4. INSERT INTO customer PARTITION (state = 'CA', city = 'Fremont') VALUES (100, 'John');
    5. INSERT INTO customer PARTITION (state = 'CA', city = 'San Jose') VALUES (200, 'Marry');
    6. INSERT INTO customer PARTITION (state = 'AZ', city = 'Peoria') VALUES (300, 'Daniel');
    7. -- Lists all partitions for table `customer`
    8. SHOW PARTITIONS customer;
    9. +----------------------+
    10. | partition|
    11. +----------------------+
    12. | state=AZ/city=Peoria|
    13. |state=CA/city=San Jose|
    14. -- Lists all partitions for the qualified table `customer`
    15. SHOW PARTITIONS salesdb.customer;
    16. +----------------------+
    17. | partition|
    18. +----------------------+
    19. | state=AZ/city=Peoria|
    20. | state=CA/city=Fremont|
    21. |state=CA/city=San Jose|
    22. +----------------------+
    23. -- Specify a full partition spec to list specific partition
    24. SHOW PARTITIONS customer PARTITION (state = 'CA', city = 'Fremont');
    25. +---------------------+
    26. | partition|
    27. +---------------------+
    28. |state=CA/city=Fremont|
    29. -- Specify a partial partition spec to list the specific partitions
    30. SHOW PARTITIONS customer PARTITION (state = 'CA');
    31. +----------------------+
    32. | partition|
    33. +----------------------+
    34. | state=CA/city=Fremont|
    35. |state=CA/city=San Jose|
    36. +----------------------+
    37. -- Specify a partial spec to list specific partition
    38. SHOW PARTITIONS customer PARTITION (city = 'San Jose');
    39. +----------------------+
    40. | partition|
    41. +----------------------+
    42. |state=CA/city=San Jose|
    43. +----------------------+