About managing dynamic tables¶
Managing dynamic tables typically involves the following tasks:
Task |
Description |
---|---|
List dynamic tables and view information about a dynamic table |
Listing and viewing dynamic tables. |
Dropping dynamic tables. |
|
Altering dynamic tables. |
List dynamic tables and view information about a dynamic table¶
To list the dynamic tables in a database and view information about those dynamic tables, you can use either Snowsight or SQL commands:
Use Snowsight to list dynamic tables and view details¶
To list the dynamic tables in a schema and view information about a dynamic table:
Sign in to Snowsight.
Select Data » Databases.
Select a database and schema.
On the Schema Details, select the Dynamic Tables tab.
Note that you can also view the list of dynamic tables in the database object explorer by expanding Dynamic Tables.
To view information about a specific dynamic table, select the dynamic table in the database object explorer or in the list of dynamic tables in the Dynamic Tables tab.
The tabs on this page provide some of the same information as the table details page, including:
The definition of the dynamic table and the privileges granted for working with the dynamic table
Information about the columns in the dynamic table
A preview of up to 100 rows of the data in the dynamic table
In addition, the dynamic table details page includes tabs that you can use to view information about the dynamic table:
The Graph tab displays the directed acyclic graph (DAG) that includes this dynamic table. See Use Snowsight to examine the graph of dynamic tables.
The Refresh History tab displays the history of refreshes. See Use Snowsight to monitor refreshes.
Use SQL commands to list dynamic tables and view details¶
To list the dynamic tables in the current database (or in the account, if no database is currently in use), use the SHOW DYNAMIC TABLES command.
For example, to list the dynamic tables with names that start with
product_
in the databasemydb
and schemamyschema
, execute the following SQL statement:SHOW DYNAMIC TABLES LIKE 'product_%' IN SCHEMA mydb.myschema;
For the full syntax of the command, see SHOW DYNAMIC TABLES.
To output information about the columns in a dynamic table, use the DESCRIBE DYNAMIC TABLE command.
For example, to list the columns in the dynamic table named
product
:DESC DYNAMIC TABLE product;
Dynamic tables are also included in the results of the TABLES view.
Drop a dynamic table¶
To drop a dynamic table, you can use either Snowsight or SQL commands.
- Snowsight:
In Snowsight, open the dynamic table details page (instructions).
On the More menu in the upper-right corner of the page, select Drop.
- SQL:
Use the DROP DYNAMIC TABLE command.
For example, to drop the dynamic table named
product
:
DROP DYNAMIC TABLE product;
Data sharing with dynamic tables¶
Dynamic tables are shareable objects. To share a dynamic table, data sharing providers grant privileges on a dynamic table to a share, which in turn can be used by data sharing consumers.
Alter the warehouse or target lag for a dynamic table¶
To change the warehouse or target lag for a dynamic table, use the ALTER DYNAMIC TABLE command.
For example, to change the warehouse for the dynamic table product
to my_other_wh
, run:
ALTER DYNAMIC TABLE product SET WAREHOUSE = my_other_wh;
The following diagram illustrates suspend, resume, and manual refresh operations in the context of upstream and downstream relationships to other dynamic tables.
The diagram depicts a simple declarative data pipeline built with dynamic tables. Similar to water flowing in a stream, data in a dynamic table pipeline flows from the root downstream toward the leaf dynamic table:
DT2 is described as downstream of DT1 because it depends on that dynamic table, and as upstream of DT3, which depends on it.
DT3 is downstream of both DT2 and DT1 because it depends on DT2 directly and on DT1 indirectly.
DT1 is directly or indirectly upstream of the other dynamic tables.
For additional details and examples of using downstream target lag, see Understanding target lag.
Determine the optimal target lag for a dynamic table¶
To determine the optimal target lag time for a dynamic table, you can use either Snowsight or SQL commands.
- Snowsight:
On the dynamic table details page, select the Refresh History tab.
Check the maximum actual lag time, which is displayed at the top of the tab. This metric is based on the actual lag time for each refresh.
- SQL:
Use the DYNAMIC_TABLE_REFRESH_HISTORY table function in INFORMATION_SCHEMA. This function returns information about each refresh of a dynamic table, including the time taken for the refresh and which refreshes were skipped.
The lag time that you choose can affect the refresh schedule determined by the automated refresh process. The automated refresh process chooses a schedule that best meets the lag times of the dynamic tables.
Determine whether an incremental or full refresh is used¶
To determine whether an incremental or full refresh is used to update a dynamic table, you can use either Snowsight or SQL commands.
- Snowsight:
Go to the dynamic table details page.
The basic details at the top of the page indicate whether incremental or full refreshes are used for that table.
- SQL:
Use the SHOW DYNAMIC TABLES command, and check the value of the
REFRESH_MODE
column in the output.REFRESH_MODE_REASON contains additional details on the choice of REFRESH_MODE.
Understanding the effects of changes to columns in base tables¶
The columns in the base tables, views, and underlying dynamic tables can change over time. Some changes can affect the dynamic table itself; others may have limited or no impact.
When the underlying objects associated with a dynamic table change, the following behaviors apply:
Change |
Impact |
---|---|
|
None. If a new column is added to the base table or an unused column is deleted, no action occurs and refreshes continue as before. |
|
Full refresh/reinitialize: During the next refresh cycle, a full refresh is done to ensure that no incorrect or stale data is in the dynamic table. |
|
The state of the dynamic table changes to FAILED. The dynamic table must be recreated to respond to the change. |
Understanding auto-suspend behavior¶
Note
A dynamic table is suspended if the system observes five continuous refresh errors. Dynamic tables suspended due to refresh errors are commonly referred to as auto-suspended because they are suspended by the system and not through user action.
Any dynamic tables that depend on the suspended dynamic table are also suspended. SCHEDULING_STATE describes the current state of a dynamic table.
To view the scheduling state of the dynamic table, call the DYNAMIC_TABLE_GRAPH_HISTORY table function, and examine the SCHEDULING_STATE column.