查看表结构
功能概述
DESC
DESC
(或
DESCRIBE
DESCRIBE
)查看表、视图、物化视图、动态表的列结构。加
EXTENDED
EXTENDED
后还能看到创建时间、存储格式、行数、动态表刷新配置、DEFAULT 值等完整元数据。
语法
DESC[RIBE] [TABLE] [EXTENDED] <table_name>;
TABLE
TABLE
:可选,指定对象是表,通常可省略
EXTENDED
EXTENDED
:查看扩展信息(创建时间、类型、统计信息等)
- 适用对象:普通表(TABLE)、视图(VIEW)、物化视图(MATERIALIZED VIEW)、动态表(DYNAMIC TABLE)
使用示例
查看普通表列结构
DESC employees;
+-------------+---------------+---------+
| column_name | data_type | comment |
+-------------+---------------+---------+
| id | int | |
| name | string | |
| skills | array<string> | |
+-------------+---------------+---------+
查看扩展信息(含统计数据)
DESC EXTENDED employees;
+------------------------------+-------------------------+---------+
| column_name | data_type | comment |
+------------------------------+-------------------------+---------+
| id | int | |
| name | string | |
| skills | array<string> | |
| | | |
| # detailed table information | | |
| schema | public | |
| name | employees | |
| creator | qiliang | |
| created_time | 2026-06-13 10:18:52.988 | |
| last_modified_time | 2026-06-13 10:18:52.988 | |
| comment | | |
| properties | () | |
| type | TABLE | |
| format | PARQUET | |
| statistics | 3 rows 2548 bytes | |
+------------------------------+-------------------------+---------+
查看带 DEFAULT 值的表
含有 DEFAULT 列的表,
DESC EXTENDED
DESC EXTENDED
会在末尾额外输出
# Column Default Values
# Column Default Values
段:
CREATE TABLE events (
id INT,
name STRING DEFAULT 'unknown',
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
DESC EXTENDED events;
...(列定义段)...
| # Column Default Values | | |
| name | string | 'unknown' |
| ts | timestamp_ltz | CURRENT_TIMESTAMP() |
⚠️ 注意:
# Column Default Values
# Column Default Values
段只在有 DEFAULT 列时出现。
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP
写入时会被记录为
CURRENT_TIMESTAMP()
CURRENT_TIMESTAMP()
。
查看动态表
DESC EXTENDED my_dynamic_table;
动态表
DESC EXTENDED
DESC EXTENDED
在普通表字段基础上额外包含:
| 字段 | 说明 |
|---|
type
type | DYNAMIC TABLE
DYNAMIC TABLE |
view_text
view_text | 引擎解析后的 SQL(全限定名) |
view_original_text
view_original_text | 创建时的原始 SQL |
source_tables
source_tables | 上游表列表,包含 workspace/schema/table_name |
refresh_type
refresh_type | 刷新方式,如 on schedule
on schedule |
refresh_interval_second
refresh_interval_second | 刷新间隔(秒) |
refresh_vcluster
refresh_vcluster | 刷新使用的集群 |
statistics
statistics | 行数和存储字节 |
注意事项
DESC
DESC
(不加 EXTENDED
EXTENDED
)对动态表返回列定义,但 statistics
statistics
等元数据需加 EXTENDED
EXTENDED
才能看到
DESC DYNAMIC TABLE <name>
DESC DYNAMIC TABLE <name>
和 DESC TABLE <name>
DESC TABLE <name>
效果相同,都是返回列定义
- 动态表的完整运行状态(刷新历史、增量/全量模式)通过
SHOW DYNAMIC TABLE REFRESH HISTORY
SHOW DYNAMIC TABLE REFRESH HISTORY
查看,不在 DESC EXTENDED
DESC EXTENDED
里
相关文档