BLOB Data Type

Description

The BLOB data type stores unstructured binary large objects. BLOB objects can be thought of as bitstreams with no character set semantics. (Oracle SQL Language Reference BLOB Data Type).

BLOB Data Type is not supported in Snowflake. BINARY is used instead.

Sample Source Patterns

BLOB in Create Table

Oracle

CREATE TABLE blobtable( blob_column BLOB, empty_column BLOB );

INSERT INTO blobtable VALUES (NULL, EMPTY_BLOB());

Snowflake

CREATE OR REPLACE TABLE PUBLIC.blobtable(
blob_column BINARY /*** MSC-WARNING - MSCEWI1036 - BLOB DATA TYPE CONVERTED TO BINARY ***/,
empty_column BINARY /*** MSC-WARNING - MSCEWI1036 - BLOB DATA TYPE CONVERTED TO BINARY ***/);

INSERT INTO PUBLIC.blobtable VALUES (NULL, TO_BINARY(' '));

Retrieving Data

Oracle

SELECT * FROM blobtable;

Snowflake

SELECT * FROM PUBLIC.blobtable;

Functional Example

This example is not a translation of SnowConvert, it is only used to show the functional equivalence between Oracle BLOB and Snowflake BINARY

We are using "utl_raw.cast_to_raw" and "DBMS_LOB.SUBSTR" functions. The conversion for these functions is currently not supported by SnowConvert.

Oracle

INSERT INTO blobtable VALUES(
utl_raw.cast_to_raw('hello world'), EMPTY_BLOB());

SELECT DBMS_LOB.SUBSTR(blob_column) AS result
FROM blobtable;

Snowflake

INSERT INTO blobtable (blob_column, empty_column)
SELECT TO_BINARY(hex_encode('hello world')), TO_BINARY(' ');

SELECT hex_decode_string(to_varchar(blob_column)) AS result
FROM blobtable;

Known Issues

1. The difference in max length BLOB (Oracle) and BINARY (Snowflake)

An Oracle BLOB column's maximum size is (4 gigabytes - 1) * (database block size), but Snowflake BINARY is limited to 8MB.

2. Empty value with EMPTY_BLOB

Initializing a column using EMPTY_BLOB() will return an empty LOB locator. While after translation the column will return a string with ' '.

3. No access to the DBMS_LOB built-in package

Since LOB data types are not supported in Snowflake there is not an equivalent for the DBMS_LOB functions and there are no implemented workarounds yet.

  1. MSCEWI1036: Data type converted to another data type.

Last updated