描述數據庫表

返回表的基本元數據信息。元數據信息包括列名、列類型和列注釋。您可以指定分區規範或列名,以分別返回與分區或列相關的元數據。

語法

DESC|描述表格擴展|格式化table_name分區條款|column_name

參數

  • 擴展格式化

    如果指定,則顯示指定列的詳細信息,包括命令收集的列統計信息,以及附加的元數據信息(例如模式限定符、所有者和訪問時間)。

  • table_name

    標識要描述的表。名稱不能使用時間規範

  • 分區條款

    一個可選參數,指示Databricks SQL返回指定分區的添加元數據。

  • column_name

    帶有需要描述的列名的可選參數。目前不允許指定嵌套列。

參數partition_spec而且column_name是互斥的,不能一起指定。

例子

—創建表“customer”。假設當前模式為' salesdb '。CREATE TABLE customer(cust_id INT, state VARCHAR(20), name STRING COMMENT '短名')USING parquet PARTITIONED BY (state);> INSERT INTO customer PARTITION (state = 'AR') VALUES (100, 'Mike');——返回不合格表' customer ' >的基本元數據信息;col_name data_type comment ----------------------- ------------------- cust_id int null name string短名稱state string null #分區信息# col_name data_type comment state string null——返回合格表' customer '的基本元數據信息> description table salesdb.customer;col_name data_type comment ----------------------- ------------------- cust_id int null name string短名稱state string null #分區信息# col_name data_type comment state string null——返回額外的元數據,如父模式、所有者、訪問時間等。col_name data_type comment ---------------------------- ------------------------------ ---------- cust_id int null name string短名state string null #分區信息# col_name data_type comment state string null #詳細表信息數據庫default表customer Owner < Table Owner > Created Time Tue Apr 07 22:56:34 JST 2020 Last Access UNKNOWN Created By  Type MANAGED Provider parquet Location file:/tmp/salesdb.db/custom…Serde圖書館org.apache.hadoop.hive.ql.i……InputFormat org.apache.hadoop.hive.ql.i…… OutputFormat org.apache.hadoop.hive.ql.i... Partition Provider Catalog -- Returns partition metadata such as partitioning column name, column type and comment. > DESCRIBE TABLE EXTENDED customer PARTITION (state = 'AR'); col_name data_type comment ------------------------------ ------------------------------ ---------- cust_id int null name string Short name state string null # Partition Information # col_name data_type comment state string null # Detailed Partition Inform... Database default Table customer Partition Values [state=AR] Location file:/tmp/salesdb.db/custom... Serde Library org.apache.hadoop.hive.ql.i... InputFormat org.apache.hadoop.hive.ql.i... OutputFormat org.apache.hadoop.hive.ql.i... Storage Properties [serialization.format=1, pa... Partition Parameters {transient_lastDdlTime=1586... Created Time Tue Apr 07 23:05:43 JST 2020 Last Access UNKNOWN Partition Statistics 659 bytes # Storage Information Location file:/tmp/salesdb.db/custom... Serde Library org.apache.hadoop.hive.ql.i... InputFormat org.apache.hadoop.hive.ql.i... OutputFormat org.apache.hadoop.hive.ql.i... ------------------------------ ------------------------------ ---------- -- Returns the metadata for `name` column. -- Optional `TABLE` clause is omitted and column is fully qualified. > DESCRIBE customer salesdb.customer.name; info_name info_value --------- ---------- col_name name data_type string comment Short name

描述的細節

[schema_name描述細節。]table_name描述的細節delta.``

返回關於模式、分區、表大小等的信息。例如,對於Delta表,您可以看到當前的Reader和writer版本的一個表。看到詳細模式對於詳細模式。