REFRESH(具体化视图和流式处理表)

适用于:check marked yes Databricks SQL

重要

此功能目前以公共预览版提供。 要注册以进行访问,请填写此表格

刷新流式处理表或具体化视图的数据。 数据以异步方式刷新。 可以通过执行 DESCRIBE EXTENDED 来跟踪刷新状态。

语法

REFRESH { MATERIALIZED VIEW | [ STREAMING ] TABLE } table_name [ FULL ]

参数

  • table_name

    标识要刷新的具体化视图或流式处理表。 名称不得包含时态规范。 如果找不到对象,Azure Databricks 会引发 TABLE_OR_VIEW_NOT_FOUND 错误。

  • FULL

    是否执行完全刷新,完全刷新会截断表,并使用流式处理表的最新定义处理源中可用的所有数据。 具体化视图不支持完全刷新。

    不建议对不保留整个数据历史记录或保留期较短的源(如 Kafka)调用完全刷新,因为完全刷新会截断现有数据。 如果数据在源中不再可用,则可能无法恢复旧数据。

示例

-- Refreshes the materialized view to reflect the latest available data
> REFRESH MATERIALIZED VIEW catalog.schema.view_name;

-- Refreshes the streaming table to process the latest available data
-- The current catalog and schema will be used to qualify the table
> REFRESH STREAMING TABLE st_name;

-- Truncates the table and processes all data from scratch for the streaming table
> REFRESH TABLE cat.db.st_name FULL;