DESCRIBE TABLE
適用于: Databricks SQL Databricks Runtime
傳回資料表的基本中繼資料資訊。 中繼資料資訊包括資料行名稱、資料行類型和資料行批註。 您可以選擇性地指定資料分割規格或資料行名稱,分別傳回與資料分割或資料行相關的中繼資料。 使用 Delta 資料表時,不會傳回所有欄位。
語法
{ DESC | DESCRIBE } [ TABLE ] [ EXTENDED | FORMATTED ] table_name { [ PARTITION clause ] | [ column_name ] }
參數
EXTENDED
或FORMATTED
如果指定顯示指定資料行的詳細資訊,包括命令所收集的資料行統計資料,以及其他中繼資料資訊, (例如架構限定詞、擁有者和存取時間) 。
-
識別要描述的資料表。 名稱不能使用 時態規格。 如果找不到資料表,Azure Databricks 就會引發 TABLE_OR_VIEW_NOT_FOUND 錯誤。
-
選擇性參數,指示 Databricks SQL 傳回具名分割區的加法中繼資料。
-
具有需要描述之資料行名稱的選擇性參數。 目前不允許指定巢狀資料行。
參數 partition_spec
和 column_name
互斥且不能同時指定。
例子
-- Creates a table `customer`. Assumes current schema is `salesdb`.
> CREATE TABLE customer(
cust_id INT,
state VARCHAR(20),
name STRING COMMENT 'Short name'
)
USING parquet
PARTITIONED BY (state);
> INSERT INTO customer PARTITION (state = 'AR') VALUES (100, 'Mike');
-- Returns basic metadata information for unqualified table `customer`
> DESCRIBE TABLE customer;
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
-- Returns basic metadata information for qualified table `customer`
> DESCRIBE TABLE salesdb.customer;
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
-- Returns additional metadata such as parent schema, owner, access time etc.
> DESCRIBE TABLE EXTENDED customer;
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 Table Information
Database default
Table customer
Owner <TABLE OWNER>
Created Time Tue Apr 07 22:56:34 JST 2020
Last Access UNKNOWN
Created By <SPARK VERSION>
Type MANAGED
Provider parquet
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...
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
描述詳細資料
DESCRIBE DETAIL [schema_name.]table_name
DESCRIBE DETAIL delta.`<path-to-table>`
傳回架構、資料分割、資料表大小等的相關資訊。 例如,針對 Delta 資料表,您可以看到資料表目前的 讀取器和寫入器版本 。 如需 詳細架構的詳細資料,請參閱檢閱 Delta Lake 資料表詳細 資料。