查看表结构(DESC TABLE)

功能概述

DESC TABLE
DESC TABLE
命令用于查看表的详细结构信息,包括字段名、数据类型、注释等。支持普通表、外部表、动态表、物化视图和视图。

语法

DESC[RIBE] [TABLE] [EXTENDED] <table_name>;

参数说明

参数说明
DESC
DESC
/
DESCRIBE
DESCRIBE
两者等价,可互换使用
TABLE
TABLE
可选关键字
EXTENDED
EXTENDED
可选。加上后返回更多扩展信息,如存储位置、连接信息、分区信息等
table_name
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 TABLE
    DESC TABLE
    适用于所有表类型:普通表、外部表、动态表、物化视图
  • 对于动态表,
    EXTENDED
    EXTENDED
    模式额外返回刷新配置、源表、查询定义等信息
  • 对于外部表,
    EXTENDED
    EXTENDED
    模式额外返回存储位置、连接信息等

相关文档

联系我们
预约咨询
微信咨询
电话咨询
邮件咨询