A working reference for dbt Core: the commands you run daily, the node selection syntax that saves you from rebuilding the whole project, and the config blocks that decide how a model lands in the warehouse. Everything here is dbt 1.5 or later, and the same commands work in the dbt Cloud IDE.
dbt debugdbt depsdbt rundbt compile
# output lands in target/compiled/dbt testdbt seed --full-refreshdbt snapshotdbt docs generate
dbt docs servedbt cleandbt run --select ordersdbt run --select orders+dbt run --select +ordersdbt run --select 1+orders+1dbt run --select path:models/martsdbt run --select tag:dailydbt run --select source:stripe+dbt run --select marts.* --exclude tag:slowdbt run --select "state:modified+" --state ./prod-artifactsdbt build --select result:error+ --state ./targetdbt run --select orders --full-refresh{{ config(materialized='table') }}
select * from {{ ref('stg_orders') }}models:
my_project:
marts:
+materialized: table
+tags: [daily]select * from {{ ref('stg_orders') }}select * from {{ source('stripe', 'charges') }}version: 2
sources:
- name: stripe
schema: raw_stripe
tables:
- name: charges{{ config(materialized='incremental', unique_key='id') }}
select * from {{ ref('stg_orders') }}
{% if is_incremental() %}
where updated_at > (select max(updated_at) from {{ this }})
{% endif %}{% snapshot orders_snapshot %}
{{ config(unique_key='id', strategy='timestamp', updated_at='updated_at') }}
select * from {{ source('app', 'orders') }}
{% endsnapshot %}{{ config(post_hook='grant select on {{ this }} to role analyst') }}version: 2
models:
- name: orders
description: One row per customer order.
columns:
- name: id
tests: [unique, not_null]
- name: customer_id
tests:
- relationships:
to: ref('customers')
field: id - name: status
tests:
- accepted_values:
values: ['new', 'shipped', 'cancelled']-- tests/assert_totals_positive.sql
select * from {{ ref('orders') }} where total < 0{% test positive(model, column_name) %}
select * from {{ model }} where {{ column_name }} < 0
{% endtest %}dbt test --store-failuresdbt test --select ordersvars:
start_date: '2026-01-01'where day >= '{{ var('start_date', '2026-01-01') }}'dbt run --vars '{"start_date": "2026-08-01"}'{% macro cents_to_euros(column_name) %}
({{ column_name }} / 100.0)::numeric(10,2)
{% endmacro %}packages:
- package: dbt-labs/dbt_utils
version: [">=1.1.0", "<2.0.0"]select {{ dbt_utils.generate_surrogate_key(['order_id', 'line_no']) }} as id{% for status in ['new', 'shipped'] %}
sum(case when status = '{{ status }}' then 1 else 0 end) as {{ status }}_count{{ ',' if not loop.last }}
{% endfor %}my_project:
target: dev
outputs:
dev:
type: postgres
host: localhost
user: "{{ env_var('DBT_USER') }}"
password: "{{ env_var('DBT_PASSWORD') }}"
dbname: analytics
schema: dbt_kim
threads: 4dbt run --target prodEach guide is a short answer with examples you can copy and run, plus the gotchas and errors that come with it.
Run dbt queries without a desktop client
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free© 2026 Panda Capital Oy Ab. All rights reserved.