By Rohit Ray · Independent educational lesson · Explore this visual lab

Module 12 · Lesson 1 of 9Detailed study · about 20 min

What a dynamic table remembers

A dynamic table stores the result of a query and refreshes it as its sources change. You describe the desired result; Snowflake manages the refresh work.

Understand the idea

Imagine a dashboard showing sales per customer. With ordinary tables you might write a procedure to update totals. With a dynamic table you define the SELECT that computes those totals and give Snowflake a freshness goal.

Key ideas in simple English
ConceptWhat it means
Ordinary tableYou explicitly insert, update or delete its rows.
ViewStores a query definition evaluated when queried.
Dynamic tableStores a query result maintained by refreshes.
DeclarativeDescribe the desired result instead of each processing step.

A concrete example

Imagine a dashboard showing sales per customer. With ordinary tables you might write a procedure to update totals. With a dynamic table you define the SELECT that computes those totals and give Snowflake a freshness goal.

Remember: Define a dynamic table and its query explicitly; an ordinary source table alone does not maintain derived results.

Explain it step by step · full theory

Understand the concept

Imagine a dashboard showing sales per customer. With ordinary tables you might write a procedure to update totals. With a dynamic table you define the SELECT that computes those totals and give Snowflake a freshness goal.

The result is stored, so a dashboard reads the last successfully refreshed data. That is different from rerunning the full source query every time somebody opens the report. A dynamic table is not a transaction trigger and does not promise immediate updates.

Apply it to our pipeline

Create a separate M12_LAB schema. Use the existing Module 03 database, an authorized role and a warehouse you are allowed to use. The creator needs CREATE DYNAMIC TABLE on the schema, appropriate source SELECT and database/schema/warehouse USAGE. Incremental sources need change tracking and sufficient retention; enabling tracking may require the source owner.

Our small fixture has three orders. One is cancelled. Keep these as current source rows rather than copying the immutable event ledger from Module 11: the two models solve different input contracts. Run setup once; use a fresh lab schema if objects already exist.

Words used in this lesson
Ordinary table
You explicitly insert, update or delete its rows.
View
Stores a query definition evaluated when queried.
Dynamic table
Stores a query result maintained by refreshes.
Declarative
Describe the desired result instead of each processing step.

See how it works

Choose a step to explore the idea at your own pace.

Open the interactive explanation
Interactive explainer1 / 2

What a dynamic table remembers

RAW_ORDERS
CLEAN_ORDERS
CUSTOMER_TOTALS

Read the dependency

A dynamic table stores the result of a query and refreshes it as its sources change. You describe the desired result; Snowflake manages the refresh work.

Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.

Read the complete diagram explanation
  1. Read the dependency

    A dynamic table stores the result of a query and refreshes it as its sources change. You describe the desired result; Snowflake manages the refresh work.

  2. Observe the result

    Three rows: A has two paid orders totalling 150; B has one cancelled order. No dynamic tables exist yet.

Try the SQL or command

Read → predict → run in your learning environment → compare. You can also learn by reading without an account.

New to SQL? Where to run it and how to read it

A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.

  1. No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
  2. For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
  3. Read the entire example, including comments beginning with --. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor.
  4. Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
SELECT / FROM
Choose the values to return / identify their input.
VALUES / COLUMN1
VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
AS / WITH
AS gives a result a readable name. WITH names a temporary query step within one statement.
NULL / ::
NULL means missing or unknown. The :: notation converts a value to a named data type.
Session
One connection and its settings. Keep related transaction steps in the same session.
Database.schema.table
A full address for stored data. It is separate from the warehouse that processes queries.

Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →

Help with common practice errors
  • No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
  • Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
  • Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
  • Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.

Before running this lesson

Manual Snowflake practice only. This website does not run SQL or provision compute. Refreshing dynamic tables uses billable resources.

What a dynamic table remembers — manual SQL

Definition: A dynamic table stores the result of a query and refreshes it as its sources change. You describe the desired result; Snowflake manages the refresh work.

When to use: Practise in the isolated M12_LAB schema.

Example: Three rows: A has two paid orders totalling 150; B has one cancelled order. No dynamic tables exist yet.

SQL · example
USE DATABASE L2_OBJECTS_LAB;
CREATE SCHEMA M12_LAB;
USE SCHEMA M12_LAB;
CREATE TABLE RAW_ORDERS (
 ORDER_ID NUMBER, CUSTOMER_ID VARCHAR, AMOUNT NUMBER(12,2), STATUS VARCHAR
) CHANGE_TRACKING=TRUE;
INSERT INTO RAW_ORDERS VALUES
 (101,'A',100,'PAID'),(102,'A',50,'PAID'),(103,'B',80,'CANCELLED');
SELECT * FROM RAW_ORDERS ORDER BY ORDER_ID;

What to expect and why

Three rows: A has two paid orders totalling 150; B has one cancelled order. No dynamic tables exist yet.

Check your understanding

Choose an answer, then check your reasoning. This is practice, not a scored test.

Does creating a source table also create an automatic transformation?

Try it yourself

Explain why: Does creating a source table also create an automatic transformation?

Compare your reasoning

Define a dynamic table and its query explicitly; an ordinary source table alone does not maintain derived results.

Official sources and curriculum

Module 12 · See module scope