SHOW TBLPROPERTIES

适用于:check marked yes Databricks SQL check marked yes Databricks Runtime

鉴于属性键的可选值,返回表属性的值。 如果未指定任何键,则返回所有属性和选项。 表选项以 option 作为前缀。

语法

SHOW TBLPROPERTIES table_name
   [ ( [unquoted_property_key | property_key_as_string_literal] ) ]

unquoted_property_key
  key_part1 [. ...]

参数

  • table_name

    标识表。 名称不得包含时态规范

  • unquoted_property_key

    不加引号的属性键。 键可以包含用点分隔的多个部分。

  • property_key_as_string_literal

    字符串字面量形式的属性键值。

注意

此语句返回的属性值不包括 spark 和 hive 内部的某些属性。 排除的属性包括:

  • 以前缀 spark.sql 开头的所有属性
  • 属性键,例如 EXTERNALcomment
  • 由 hive 在内部生成的用于存储统计信息的所有属性。 其中一些属性包括:numFilesnumPartitionsnumRows

示例

-- create a table `customer` in schema `salessc`
> USE salessc;
> CREATE TABLE customer(cust_code INT, name VARCHAR(100), cust_addr STRING)
    TBLPROPERTIES ('created.by.user' = 'John', 'created.date' = '01-01-2001');

-- show all the user specified properties for table `customer`
> SHOW TBLPROPERTIES customer;
                   key      value
 --------------------- ----------
       created.by.user       John
          created.date 01-01-2001
 transient_lastDdlTime 1567554931

-- show all the user specified properties for a qualified table `customer`
-- in schema `salessc`
> SHOW TBLPROPERTIES salessc.customer;
                   key      value
 --------------------- ----------
       created.by.user       John
          created.date 01-01-2001
 transient_lastDdlTime 1567554931

-- show value for unquoted property key `created.by.user`
> SHOW TBLPROPERTIES customer (created.by.user);
 value
 -----
  John

-- show value for property `created.date`` specified as string literal
> SHOW TBLPROPERTIES customer ('created.date');
      value
 ----------
 01-01-2001