database
- Model
- Seeds
- Snapshots
- Tests
Specify a custom database for a model in your dbt_project.yml
file.
For example, if you have a model that you want to load into a database other than the target database, you can configure it like this:
models:
your_project:
sales_metrics:
+database: reporting
This would result in the generated relation being located in the reporting
database, so the full relation name would be reporting.finance.sales_metrics
instead of the default target database.
Configure a database in your dbt_project.yml
file.
For example, to load a seed into a database called staging
instead of the target database, you can configure it like this:
seeds:
your_project:
product_categories:
+database: staging
This would result in the generated relation being located in the staging
database, so the full relation name would be staging.finance.product_categories
.
Customize the database for storing test results in your dbt_project.yml
file.
For example, to save test results in a specific database, you can configure it like this:
tests:
+store_failures: true
+database: test_results
This would result in the test results being stored in the test_results
database.
Definition
Optionally specify a custom database for a model, seed, or data test. (To specify a database for a snapshot, use the target_database
config).
When dbt creates a relation (table/view) in a database, it creates it as: {{ database }}.{{ schema }}.{{ identifier }}
, e.g. analytics.finance.payments
The standard behavior of dbt is:
- If a custom database is not specified, the database of the relation is the target database (
{{ target.database }}
). - If a custom database is specified, the database of the relation is the
{{ database }}
value.
To learn more about changing the way that dbt generates a relation's database
, read Using Custom Databases
Warehouse specific information
- BigQuery:
project
anddatabase
are interchangeable