Convert Oracle DDL to dbt models compatible with Snowflake...
Transform Oracle DDL (views, tables, stored procedures, packages) into production-quality dbt models compatible with Snowflake, maintaining the same business logic and data transformation steps while following dbt best practices.
Activate this skill when users ask about:
Do NOT begin manual conversion. Oracle has full SnowConvert AI support (tables, views, procedures, functions, packages). Before writing any dbt model by hand:
- Run SnowConvert AI on the source DDL to produce Snowflake-compatible SQL.
- Use the
$dbt-migration-snowflakeskill to convert the SCAI output to dbt models.- Only fall back to this skill's manual translation rules for objects SCAI could not convert (check the conversion report for EWIs).
See the
$dbt-migrationskill for download links and full workflow.
Preserve original object names. The dbt model filename and model name MUST match the original source object name (lowercased, without schema prefix). For example,
HR.EMPLOYEE_BENEFITSbecomesemployee_benefits.sql. Do not rename objects during migration unless explicitly requested by the user.
You are a database engineer working for a hospital system. You need to convert Oracle DDL to equivalent dbt code compatible with Snowflake, maintaining the same business logic and data transformation steps while following dbt best practices.
I will provide you the Oracle DDL to convert.
The code will be executed by data engineers who are learning Snowflake and dbt.
Generate the following:
-- dbt model: models/[domain]/[target_schema_name]/model_name.sql
{{ config(materialized='view') }}
/* Original Object: [owner].[object_name]
Source Platform: Oracle
Purpose: [brief description]
Conversion Notes: [key changes]
Description: [SQL logic description] */
WITH source_data AS (
SELECT
customer_id::INTEGER AS customer_id,
customer_name::VARCHAR(100) AS customer_name,
account_balance::NUMBER(18,2) AS account_balance,
-- Oracle DATE includes time, converted to TIMESTAMP_NTZ
created_date::TIMESTAMP_NTZ AS created_date
FROM {{ ref('upstream_model') }}
),
transformed_data AS (
SELECT
customer_id,
UPPER(customer_name)::VARCHAR(100) AS customer_name_upper,
account_balance,
created_date,
CURRENT_TIMESTAMP()::TIMESTAMP_NTZ AS loaded_at
FROM source_data
)
SELECT
customer_id,
customer_name_upper,
account_balance,
created_date,
loaded_at
FROM transformed_data
## models/[domain]/[target_schema_name]/_models.yml
version: 2
models:
- name: model_name
description: "Table description; converted from Oracle [Original object name]"
columns:
- name: customer_id
description: "Primary key - unique customer identifier"
tests:
- unique
- not_null
- name: customer_name_upper
description: "Customer name in uppercase"
- name: account_balance
description: "Current account balance; Foreign key to OTHER_TABLE"
tests:
- relationships:
to: ref('OTHER_TABLE')
field: OTHER_TABLE_KEY
- name: created_date
description: "Date the customer record was created"
- name: loaded_at
description: "Timestamp when the record was loaded by dbt"
## dbt_project.yml (excerpt)
models:
my_project:
+materialized: view
domain_name:
+schema: target_schema_name
::TYPE syntax (e.g.,
column_name::VARCHAR(100), amount::NUMBER(18,2)) to ensure output matches expected data types| Oracle | Snowflake | Notes |
|---|---|---|
| NUMBER | NUMBER | |
| INTEGER/INT | INTEGER | Alias for NUMBER(38,0) |
| FLOAT/BINARY_FLOAT/BINARY_DOUBLE | FLOAT | |
| CHAR/VARCHAR2/NCHAR/NVARCHAR2 | CHAR/VARCHAR | VARCHAR2 → VARCHAR |
| CLOB/NCLOB | VARCHAR | Max 16MB |
| BLOB/RAW/LONG RAW | BINARY | Max 8MB |
| DATE | TIMESTAMP_NTZ | Oracle DATE includes time! |
| TIMESTAMP | TIMESTAMP_NTZ | |
| TIMESTAMP WITH TIME ZONE | TIMESTAMP_TZ | |
| TIMESTAMP WITH LOCAL TIME ZONE | TIMESTAMP_LTZ | |
| INTERVAL types | VARCHAR | |
| ROWID/UROWID | VARCHAR | |
| JSON | VARIANT | |
| XMLType | VARIANT |
-- ROWNUM → ROW_NUMBER()
WHERE ROWNUM <= 10 → QUALIFY ROW_NUMBER() OVER (ORDER BY 1) <= 10
-- CONNECT BY → Recursive CTE
SELECT ... START WITH ... CONNECT BY PRIOR → WITH RECURSIVE cte AS (...)
-- NVL/NVL2 → COALESCE/IFF
NVL(col, 0) → COALESCE(col, 0)
NVL2(col, 'yes', 'no') → IFF(col IS NOT NULL, 'yes', 'no')
-- DECODE → CASE
DECODE(col, 1, 'A', 2, 'B', 'C') → CASE col WHEN 1 THEN 'A' WHEN 2 THEN 'B' ELSE 'C' END
-- (+) outer join → ANSI JOIN
FROM a, b WHERE a.id = b.id(+) → FROM a LEFT JOIN b ON a.id = b.id
-- SYSDATE/SYSTIMESTAMP → CURRENT_DATE/CURRENT_TIMESTAMP
SYSDATE → CURRENT_DATE()
-- DUAL table → Optional in Snowflake
SELECT 1 FROM DUAL → SELECT 1
-- TO_DATE format differences
TO_DATE('2024-01-15', 'YYYY-MM-DD') → TO_DATE('2024-01-15', 'YYYY-MM-DD')
| Oracle | Snowflake | Notes |
|---|---|---|
NVL(a, b) |
NVL(a, b) or COALESCE(a, b) |
Same |
NVL2(a, b, c) |
IFF(a IS NOT NULL, b, c) |
|
DECODE(col, ...) |
CASE col WHEN ... END |
|
ROWNUM |
ROW_NUMBER() OVER (...) |
Use with QUALIFY |
SYSDATE |
CURRENT_DATE() or CURRENT_TIMESTAMP() |
|
SYSTIMESTAMP |
CURRENT_TIMESTAMP() |
|
TO_CHAR(d, fmt) |
TO_CHAR(d, fmt) |
Format codes same |
TO_DATE(s, fmt) |
TO_DATE(s, fmt) |
Format codes same |
TO_NUMBER(s) |
TO_NUMBER(s) |
Same |
TRUNC(d) |
DATE_TRUNC('day', d) |
For dates |
TRUNC(n, d) |
TRUNC(n, d) |
For numbers, same |
ADD_MONTHS(d, n) |
DATEADD('month', n, d) |
|
MONTHS_BETWEEN(d1, d2) |
DATEDIFF('month', d2, d1) |
Arg order differs |
SUBSTR(s, pos, len) |
SUBSTR(s, pos, len) |
Same |
INSTR(s, search) |
POSITION(search IN s) |
|
REGEXP_LIKE(s, p) |
REGEXP_LIKE(s, p) |
Same |
LISTAGG(col, delim) |
LISTAGG(col, delim) |
Same |
DBMS_OUTPUT.PUT_LINE |
Remove or use SYSTEM$LOG |
| Database | Key Considerations |
|---|---|
| Oracle | PL/SQL, DBMS_* packages, ROWNUM/ROWID, CONNECT BY, sequences, collections/records, wrapped objects, DATE includes time |
Detailed syntax translation guides are available in the translation-references/ folder.
Copyright Notice: The translation reference documentation in this repository is derived from Snowflake SnowConvert Documentation and is © Copyright Snowflake Inc. All rights reserved. Used for reference purposes only.