手动刷新动态表¶
You can manually refresh a dynamic table to include the latest data without waiting for the next scheduled refresh. This is useful for one-time updates or when a table has a large target lag and the next refresh occurs much later.
小技巧
避免对具有下游动态表的动态表频繁执行手动刷新,这些下游动态表会根据目标延迟自动刷新。这类手动刷新可能会导致计划的刷新跳过,并阻止下游表更新。
To manually refresh, use the ALTER DYNAMIC TABLE ... REFRESH command or Snowsight as shown in the following steps:
ALTER DYNAMIC TABLE my_dynamic_table REFRESH
登录 Snowsight。
选择 Monitoring » Dynamic Tables。
In the list, find your dynamic table, and then select
» Refresh Manually.
对于需要精确刷新时间的情况,例如使刷新与外部系统计划或批处理窗口保持一致时,您可以使用带有 CRON 表达式的任务来触发刷新。
例如:
-- Create the task
CREATE TASK my_dt_refresh_task
WAREHOUSE = my_wh
SCHEDULE = 'USING CRON 0 0 * * * America/Los_Angeles' -- Example: daily at midnight PST
COMMENT = 'Daily 5pm PT manual refresh of my_dynamic_table'
AS
ALTER DYNAMIC TABLE my_dynamic_table REFRESH;
-- Enable the task
ALTER TASK my_dt_refresh_task RESUME;
-- Show the task
SHOW TASKS LIKE 'my_dt_refresh_task';
+------------+-----------------+-------------------------------------+---------------+-------------+--------------+-------------------------------------------------+-----------|-------------------------------------------+------------------+---------+----------------------------------------------+-----------+-----------------------------+-------------------+-------------------------------|-------------------+-----------------+--------+---------------------+-----------------------+---------------------+-----------------+----------------------------+-----------------+
| CREATED_ON | NAME | ID | DATABASE_NAME | SCHEMA_NAME | OWNER | COMMENT | WAREHOUSE | SCHEDULE | [ ] PREDECESSORS | STATE | DEFINITION | CONDITION | ALLOW_OVERLAPPING_EXECUTION | ERROR_INTEGRATION | LAST_COMMITTED_ON | LAST_SUSPENDED_ON | OWNER_ROLE_TYPE | CONFIG | TASK_RELATIONS | LAST_SUSPENDED_REASON | SUCCESS_INTEGRATION | SCHEDULING_MODE | TARGET_COMPLETION_INTERVAL | EXECUTE_AS_USER |
|------------+-----------------+-------------------------------------+---------------+-------------+--------------+-------------------------------------------------+-----------+-------------------------------------------+------------------+---------+----------------------------------------------+-----------+-----------------------------+-------------------+-------------------------------+-------------------+-----------------+--------+---------------------+-----------------------+---------------------+-----------------+----------------------------+-----------------|
| 2025-10-02 | DT_REFRESH_TASK | 01bf6f0d-690f-f373-0000-000000025e3d| mydb | my_schema | ACCOUNTADMIN | Daily 5pm PT manual refresh of my_dynamic_table | mywh | USING CRON 0 17 * * * America/Los_Angeles | [] | Started | ALTER DYNAMIC TABLE my_dynamic_table REFRESH | null | false | null | 2025-10-02 05:08:52.897 +0000 | null | ROLE | null | {"Predecessors":[]} | null | null | null | null | null |
+------------+-----------------+-------------------------------------+---------------+-------------+--------------+-------------------------------------------------+-----------|-------------------------------------------+------------------+---------+----------------------------------------------+-----------+-----------------------------+-------------------+-------------------------------|-------------------+-----------------+--------+---------------------+-----------------------+---------------------+-----------------+----------------------------+-----------------+
在大多数情况下,Snowflake 建议使用目标滞后,这样可以优化刷新频率,并相比固定 CRON 计划(可能会进行不必要的运行)可以降低成本。