Snapshot target database does not exist" dbt snapshot error
Fixes dbt snapshot failures where the configured target database is missing, by creating the database in the warehouse or removing the override so the snapshot uses the target database. Use when dbt snapshot fails naming a missing target database. Not for missing schemas, which produce a different error.
TL;DR
The snapshot block sets target_database to a database that does not exist in the warehouse. Either create that database or drop the override so the snapshot lands in the profile target's database. Then rerun dbt snapshot.
Error
"Snapshot target database does not exist" dbt snapshot errorSteps
- Open the snapshot file and find the
target_databaseconfig in its config block. Expected: you see the database name dbt is trying to use. - Check whether that database exists in the warehouse (list databases in your warehouse UI or information schema). Expected: you confirm it is genuinely missing.
- Either create the database in the warehouse, or remove the
target_databaseline so the snapshot uses the default target database. Expected: the config now points at a database that exists. - Also verify
target_schema; it must exist or be creatable by the dbt role. Expected: schema is present or the role can create it. - Run
dbt snapshot --select [SNAPSHOT NAME]. Expected: the snapshot builds successfully.
When to use
dbt snapshotfails with "target database does not exist".- You copied a snapshot config from another project with a different database name.
When not to use
- The error is about a missing schema rather than a database.
- The snapshot fails on its
unique_keyorstrategy(a config problem, not a missing database).
Tool compatibility
- dbt Core 1.0 and later. Multi-database setups apply mostly to Snowflake, BigQuery, and Databricks.
Variant phrasings
Snapshot fails: database does not exist on BigQuery
On BigQuery the "database" is the project; the fix is the same: point at a real one.
target_schema does not exist for snapshot
Sibling error: create the schema or let dbt create it with the right privileges.
Why it happens
Snapshots allow overriding the target database and schema per snapshot. A stale or copied override points at a database nobody created in this warehouse, and the snapshot has nowhere to write.
Edge cases
- The dbt role needs create-schema privileges if you expect dbt to make the schema itself.
target_databaseon warehouses without a database concept is ignored; do not set it there.- Hard-coding database names hurts portability across dev and prod; prefer leaving the default and overriding per target.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_J05h501tLq-iIuS1dxgipw
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.