Skip to main content

database

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:

dbt_project.yml
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.

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 (tableIn simplest terms, a table is the direct storage of data in rows and columns. Think excel sheet with raw values in each of the cells./viewA view (as opposed to a table) is a defined passthrough SQL query that can be run against a database (or data warehouse).) 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 and database are interchangeable
0
Loading