Configure dbt to compile, run, and test models against an Oracle database.
Running dbt on Oracle lets analytics engineers apply version-controlled transformations, tests, and documentation to long-standing Oracle data warehouses without expensive migrations.
Install the open-source dbt-oracle
adapter—built and maintained by Oracle engineers—so dbt can issue SQL through the cx_Oracle driver.
dbt-oracle
?Use pip: pip install dbt-oracle==1.8.0
. Ensure the Oracle Instant Client libraries are on the host’s LD_LIBRARY_PATH
(Linux) or on Windows PATH.
Create—or extend—~/.dbt/profiles.yml
. Each profile contains one or more targets (dev, prod, ci) with connection parameters.
profiles.yml
look like?oracle_profile:
target: dev
outputs:
dev:
type: oracle
threads: 4
host: 10.10.0.15
port: 1521
user: analytics
pass: {{ env_var('DBT_ORACLE_PW') }}
service: ORCLPDB1
schema: ANALYTICS
Run dbt debug --target dev --profile oracle_profile
. A successful run returns "All checks passed!" and prints database version and role.
Yes. Wrap any value with {{ env_var('VAR_NAME') }}
. Store secrets in a vault or CI/CD manager, keeping profiles.yml
in the repo.
Place models under /models
, then execute dbt run --models customers orders --target dev --profile oracle_profile
. dbt compiles Jinja macros to Oracle-flavored SQL and issues them through the adapter.
-- models/customer_ltv.sql
select
c.id,
c.name,
sum(o.total_amount) as lifetime_value
from {{ source('oracle', 'Customers') }} c
left join {{ ref('orders_clean') }} o
on c.id = o.customer_id
group by c.id, c.name;
Use small thread counts (≤8) to avoid cursor exhaustion, leverage materialized_view
materializations for fast incremental rebuilds, and pin adapter versions in requirements.txt
.
Set encrypted env vars (DBT_ORACLE_PW, ORACLE_HOST) in the pipeline. Run dbt deps
, dbt seed
, dbt test
, then dbt run --target prod
after passing tests.
dbt itself does not handle data loading. Use Data Pump or GoldenGate upstream, then model those tables in dbt.
Yes. The service
parameter accepts either a PDB service name or a classic SID.
Yes. When a referenced table is a synonym, Oracle resolves it transparently; no extra configuration required.
dbt-oracle defaults to uppercase unquoted identifiers. Wrap names in double quotes within models if mixed-case is required, but prefer uppercase.