dataengref migrate

Home / Oracle

Oracle to Snowflake: function mapping

3 of 15 common Oracle functions need a change in Snowflake. Mapping table with Snowflake syntax and behavior differences.

Other targets: Oracle to Databricks · Oracle to BigQuery

Needs a rewrite (3)

No Snowflake function with the same behavior; use the construct shown.

OracleSnowflakeNotes
DUALRewrite SELECT exprThe FROM clause is optional. DUAL is not described in the Snowflake SQL reference, so do not rely on it.
Sequences read with seq.NEXTVAL FROM DUAL need a different mechanism in each target (Snowflake sequences, identity columns in Databricks, GENERATE_UUID or ROW_NUMBER in BigQuery).
INSTRRewrite POSITION(substr, str [, start_pos])For the nth occurrence use REGEXP_INSTR(str, pattern, 1, n) with the substring escaped.
POSITION and CHARINDEX take the substring first, the reverse of INSTR.
ROWNUMRewrite LIMIT n / ROW_NUMBER() OVER (ORDER BY ...)QUALIFY ROW_NUMBER() OVER (...) <= n filters on the window result without a subquery.
Oracle assigns ROWNUM before ORDER BY, so WHERE ROWNUM <= 10 ... ORDER BY x returns 10 arbitrary rows sorted afterwards. Decide whether the old query meant that or "top 10 by x" before translating it to LIMIT.

Works as written (12)

The same call runs, but check the notes for behavior differences.

OracleSnowflakeNotes
ADD_MONTHSSame name ADD_MONTHS(date_or_timestamp_expr, num_months_expr)If the input is the last day of a month, the result is the last day of the result month, as in Oracle.
Snowflake DATEADD(month, ...) does not apply the last-day rule; only ADD_MONTHS does. Keep ADD_MONTHS when the Oracle behavior matters.
CONNECT BYSame name START WITH ... CONNECT BY PRIOR ...NOCYCLE, CONNECT_BY_ISCYCLE and CONNECT_BY_ISLEAF are not supported. SYS_CONNECT_BY_PATH is.
Queries using NOCYCLE need cycle-free data or a rewrite as a recursive CTE with an explicit path check.
DECODESame name DECODE(expr, search1, result1 [, ...] [, default])A NULL expr matches a NULL search value, as in Oracle.
LISTAGGSame name LISTAGG([DISTINCT] expr [, delimiter]) [WITHIN GROUP (ORDER BY ...)]Ignores NULL values; default delimiter is an empty string.
ON OVERFLOW TRUNCATE and ON OVERFLOW ERROR are Oracle only; remove the clause and check the target size limit instead.
MONTHS_BETWEENSame name MONTHS_BETWEEN(date_expr1, date_expr2)Fraction based on 31-day months; the same day of month gives a whole number.
NVLSame name NVL(expr1, expr2)Alias of IFNULL.
Oracle stores '' as NULL, so NVL(col, 'n/a') also replaces empty strings there. In the targets an empty string is not NULL; use NVL(NULLIF(col, ''), 'n/a') to keep the Oracle result.
Oracle NVL converts expr2 to the type of expr1. The targets use a common type of both arguments, which can change numeric precision or string length in the result.
NVL2Same name NVL2(expr1, expr2, expr3)Returns expr2 if expr1 is not NULL, otherwise expr3.
Oracle treats '' as NULL, so NVL2(col, 'set', 'empty') returns 'empty' for empty strings there. Add NULLIF(col, '') in the targets to keep that result.
REGEXP_SUBSTRSame name REGEXP_SUBSTR(subject, pattern [, position [, occurrence [, regex_parameters [, group_num]]]])Same argument order as Oracle.
SYSDATESame name SYSDATE()Returns TIMESTAMP_NTZ in UTC, not a DATE. Parentheses are required. CURRENT_TIMESTAMP returns local session time instead.
Oracle SYSDATE returns the operating system time of the database server. If that server ran in a local time zone, expressions such as TRUNC(SYSDATE) mean "today in local time" and will shift by hours in a UTC warehouse.
Bare SYSDATE without parentheses is an error in Snowflake.
Oracle date arithmetic such as SYSDATE - 1 (one day earlier) does not carry over to Databricks or BigQuery; use dateadd or DATETIME_SUB with an explicit unit.
TO_CHARSame name TO_CHAR(expr [, 'format'])Format elements are close to Oracle: YYYY, MM, DD, HH24, MI, SS, MON, DY.
Oracle fill mode (FM) and NLS parameters for month names have no exact equivalent; check any format that uses FM, MONTH or DAY with known dates.
TO_CHAR on numbers with format models such as '999,999.00' also differs per target; test it separately from date formats.
TO_DATESame name TO_DATE(string_expr [, 'format'])Format elements such as YYYY, MM, DD, MON work as in Oracle. Returns a DATE without time; use TO_TIMESTAMP to keep the time.
TO_DATE('2025-03-01 14:30', 'YYYY-MM-DD HH24:MI') keeps 14:30 in Oracle. The targets drop the time when parsing to DATE, so parse to a timestamp type when the time matters.
TRUNC (date)Same name TRUNC(date_or_time_expr, date_or_time_part)Same as DATE_TRUNC with the arguments swapped. Units are date parts such as 'MONTH' or 'MM'.
TRUNC(d) with no unit means 'DD' in Oracle. In the targets, write CAST(d AS DATE) or pass 'DAY'.
Oracle format models such as 'IW' (ISO week) and 'Q' map to the target's WEEK or ISOWEEK and QUARTER parts; check week starts.

Paste a query into the SQL checker to list the functions it uses that need a change.