查看表结构(DESC TABLE)
功能概述
DESC TABLE语法
DESC[RIBE] [TABLE] [EXTENDED] <table_name>;
参数说明
| 参数 | 说明 |
|---|---|
DESC / DESCRIBE | 两者等价,可互换使用 |
TABLE | 可选关键字 |
EXTENDED | 可选。加上后返回更多扩展信息,如存储位置、连接信息、分区信息等 |
table_name | 表名称,可包含 schema 前缀 |
使用示例
示例 1:查看外部表基本结构
DESC my_external_table; +-------------------------+-----------+---------+ | column_name | data_type | comment | +-------------------------+-----------+---------+ | id | int | NULL | | name | string | NULL | | dt | string | NULL | | # Partition Information | | | | # col_name | data_type | comment | | dt | string | NULL | +-------------------------+-----------+---------+
示例 2:查看外部表扩展信息
DESC EXTENDED my_external_table; +------------------------------+--------------------------------------------------------+---------+ | column_name | data_type | comment | +------------------------------+--------------------------------------------------------+---------+ | id | int | NULL | | name | string | NULL | | dt | string | NULL | | # Partition Information | | | | # col_name | data_type | comment | | dt | string | NULL | | | | | | # detailed table information | | | | schema | public | NULL | | name | my_external_table | NULL | | creator | UAT_TEST | NULL | | created_time | 2024-05-24 14:04:17.517 | NULL | | last_modified_time | 2024-05-24 14:04:17.537 | NULL | | comment | delta-external | NULL | | properties | () | NULL | | external | true | NULL | | type | TABLE | NULL | | format | delta | NULL | | location | "oss://bucket/path" | NULL | | connection | ql_ws.oss_delta | NULL | | statistics | NULL rows NULL bytes | NULL | +------------------------------+--------------------------------------------------------+---------+
注意事项
DESC TABLEDESC TABLE适用于所有表类型:普通表、外部表、动态表、物化视图- 对于动态表,
EXTENDEDEXTENDED模式额外返回刷新配置、源表、查询定义等信息 - 对于外部表,
EXTENDEDEXTENDED模式额外返回存储位置、连接信息等
