共用方式為


SHOW TBLPROPERTIES

適用於:核取記號為「是」Databricks SQL 核取記號為「是」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 在內部產生的所有屬性,以儲存統計數據。 其中一些屬性包括:numFiles、、。numPartitionsnumRows

範例

-- 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