dataengref migrate

Home / Oracle

Oracle INSTR in Snowflake, Databricks and BigQuery

BigQuery INSTR takes the same four arguments as Oracle. Snowflake has no INSTR; use POSITION or CHARINDEX, and REGEXP_INSTR for the nth occurrence. Databricks instr only takes two arguments.

Oracle function: INSTR(string, substring [, position [, occurrence]]) · Oracle docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeRewritePOSITION(substr, str [, start_pos])For the nth occurrence use REGEXP_INSTR(str, pattern, 1, n) with the substring escaped.Snowflake docs
DatabricksSame nameinstr(str, substr)Two arguments only; locate(substr, str, pos) adds a start position.Databricks docs
BigQuerySame nameINSTR(value, subvalue [, position [, occurrence]])Same arguments as Oracle, including a negative position that searches from the end.BigQuery docs

Behavior differences to check

Snowflake

Databricks

Examples

Position of the second comma

Oracle
SELECT INSTR(csv_line, ',', 1, 2) AS second_comma FROM imports;
Snowflake
SELECT REGEXP_INSTR(csv_line, ',', 1, 2) AS second_comma FROM imports;
Databricks
SELECT locate(',', csv_line, locate(',', csv_line) + 1) AS second_comma FROM imports;
BigQuery
SELECT INSTR(csv_line, ',', 1, 2) AS second_comma FROM imports;

Other Oracle functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.