# dbt Incremental Models and Snapshots, Hands-On

> Build a dbt incremental model with is_incremental() and {{ this }}, and a snapshot that keeps type 2 history, then run both twice to see what changes. Free, local, with DuckDB.

Page: https://datautility.in/blog/dbt-incremental-models-and-snapshots-hands-on
This is the Markdown copy of the page. The tool itself runs in the browser: your files are processed on your own device and are not uploaded.

Published 2026-11-28 · Analyze & protect · dbt incremental model, is_incremental, dbt snapshot, scd type 2 dbt, dbt materializations, dbt tutorial

An incremental model adds only new rows on each run instead of rebuilding the table. A snapshot keeps the history of rows that change. Both are easiest to understand by running them twice. Here is the code, and where to run it free.

Open the tool: [dbt Lab](https://datautility.in/dbtlab)

## Incremental model

```sql
{{ config(materialized='incremental', unique_key='order_date') }}

select order_date, count(*) as orders, round(sum(amount), 2) as revenue
from {{ ref('orders') }}
{% if is_incremental() %}
where order_date > (select max(order_date) from {{ this }})
{% endif %}
group by order_date
```

- The first run builds the table: `is_incremental()` is false.

- Later runs only add newer days. `{{ this }}` is the existing table. `unique_key` updates a day if it comes again.

- `dbt run --full-refresh` rebuilds it from scratch.

## Snapshot (type 2 history)

```sql
{% snapshot customers_snapshot %}
{{ config(target_schema='snapshots', unique_key='customer_id', strategy='check', check_cols=['country']) }}
select * from {{ ref('stg_customers') }}
{% endsnapshot %}
```

dbt adds dbt_valid_from and dbt_valid_to. Change a customer's country in seeds/raw_customers.csv, run dbt seed and dbt snapshot again, and the customer gets a second row: the old one closed, the new one open.

## Try it

Open the [dbt Lab](https://datautility.in/dbt-playground), go to **Going further** and run **Incremental models** and **Snapshots**. The Preview tab shows the rows after each run.

## How to use the dbt Lab: step by step

1. Start the dbt Lab and connect
2. Run the Incremental models lesson twice
3. Run the Snapshots lesson, change a seed row, run it again
4. Preview the tables

## When to use the dbt Lab

- Large fact tables that grow every day
- Keeping history of slowly changing dimensions
- Interview preparation for analytics engineering

## Also try

- [A free dbt playground](https://datautility.in/blog/free-dbt-playground-learn-dbt-without-warehouse)

## More guides

- [Data Profiler: Check Data Quality Before You Use It](https://datautility.in/blog/data-profiler-check-data-quality)
- [Compare Two CSV or Excel Files: Find Added, Removed and Changed Rows](https://datautility.in/blog/compare-two-csv-files-find-differences)
- [Data Masking: Hide Emails, Phones and Names Before Sharing](https://datautility.in/blog/data-masking-hide-emails-phones-pii)
