SnowConvert AI - Oracle - Data Types¶

This section shows equivalents between data types in Oracle and Snowflake, as well as some notes on arithmetic differences.

Oracle

Snowflake

ANSI Data Types

*Go to the link to get more information

BFILE

VARCHAR

BINARY_DOUBLE

FLOAT

BINARY_FLOAT

FLOAT

BLOB

BINARY

CHAR (N)

CHAR (N)

CLOB

VARCHAR

DATE

TIMESTAMP

FLOAT

FLOAT

INTERVAL YEAR TO MONTH

VARCHAR(20)

INTERVAL DAY TO SECOND

VARCHAR(20)

JSON

VARIANT

LONG

VARCHAR

LONG RAW

BINARY

NCHAR (N)

NCHAR (N)

NCLOB

VARCHAR

NUMBER(p, s)

NUMBER(p, s)

NVARCHAR2 (N)

VARCHAR (N)

RAW

BINARY

ROWID

VARCHAR(18)

VARCHAR2 (N)

VARCHAR (N)

SDO_GOMETRY

Currently not supported

SDO_TOPO___GEOMETRY

*to be defined

SDO_GEORASTER

*to be defined

SYS.ANYDATA

VARIANT

SYS.ANYDATASET

*to be defined

SYS.ANYTYPE

*to be defined

TIMESTAMP

TIMESTAMP

TIMESTAMP WITH TIME ZONE

TIMESTAMP_TZ

TIMESTAMP WITH LOCAL TIME ZONE

TIMESTAMP_LTZ

URITYPE

*to be defined

UROWID

VARCHAR(18)

VARCHAR

VARCHAR

VARCHAR2

VARCHAR

XMLType

VARIANT

Notes on arithmetic operations¶

Please be aware that every operation performed on numerical datatypes is internally stored as a Number. Furthermore, depending on the operation performed it is possible to incur an error related to how intermediate values are stored within Snowflake, for more information please check this post on Snowflake’s post on intermediate numbers in Snowflake.

ANSI Data Types¶

Description¶

SQL statements that create tables and clusters can also use ANSI data types and data types from the IBM products SQL/DS and DB2. Oracle recognizes the ANSI or IBM data type name that differs from the Oracle Database data type name. It converts the data type to the equivalent Oracle data type, records the Oracle data type as the name of the column data type, and stores the column data in the Oracle data type based on the conversions shown in the tables that follow. (Oracle Language Reference ANSI, DB2, and SQL/DS Data Types).

When creating a new table, Oracle and Snowflake handle some data types as synonyms and aliases and transform them into the default data type. As shown in the next table:

ANSI

ORACLE

SNOWFLAKE

CHARACTER (n)

CHAR (n)

VARCHAR

CHAR (n)

CHAR (n)

VARCHAR

CHARACTER VARYING (n)

VARCHAR2 (n)

VARCHAR

CHAR VARYING (n)

VARCHAR2 (n)

VARCHAR

NATIONAL CHARACTER (n)

NCHAR (n)

VARCHAR*

NATIONAL CHAR (n)

NCHAR (n)

VARCHAR*

NCHAR (n)

NCHAR (n)

VARCHAR

NATIONAL CHARACTER VARYING (n)

NVARCHAR2 (n)

VARCHAR*

NATIONAL CHAR VARYING (n)

NVARCHAR2 (n)

VARCHAR*

NCHAR VARYING (n)

NVARCHAR2 (n)

NUMBER (p, s)

NUMERIC [(p, s)]

NUMBER (p, s)

NUMBER (p, s)

DECIMAL [(p, s)]

NUMBER (p, s)

NUMBER (38)

INTEGER

NUMBER (38)

NUMBER (38)

INT

NUMBER (38)

NUMBER (38)

SMALLINT

NUMBER (38)

NUMBER (38)

FLOAT

FLOAT (126)

DOUBLE

DOUBLE PRECISION

FLOAT (126)

DOUBLE

REAL

FLOAT (63)

DOUBLE

To get more information about the translation specification of the Oracle data types, go to Oracle Built-in Data Types.

Note

VARCHAR*: Almost all the ANSI datatypes compile in Snowflake, but those marked with an asterisk, are manually converted to VARCHAR.

Known Issues¶

No issues were found.

Data Type Customization¶

Data Type Conversion during a database migration process is something that many users need to personalize and set up precision values more accurately. For this reason, SnowConvert AI enables the Data Type Customization to specify rules of data type transformation considering data type origin and column name.

Supported Data Types¶

The following data types are supported

  • NUMBER

Structure of JSON¶

SnowConvert AI receives a JSON file with the following structure.

{
  "types" : {
  },
  "columns": [
      {
          "nameExpression" : "",
          "targetType" : ""
      }
  ]
}
Copy

The object types defines the origin data type and the data type the target should be. Also, you might define a general rule that converts the origin data type with or without precision. For Example:

"types" : {
    "NUMBER" : "NUMBER(11, 2)",
    "NUMBER(10, 0)" : "NUMBER(3, 0)"
}
Copy

The object columns is an array, and each object of the array defines the name or the regex expression of the columns to change the type.

"columns": [
    {
        "nameExpression" : "MONTH",
        "targetType" : "NUMBER(2,0)"
    }
]
Copy

Note

When using regular expressions customization, the migration could be affected if the regex isn’t correct.

Customization Priority¶

There might be rules of customization that apply to the same object; however, only one will be chosen. SnowConvert AI will consider the following considerations to prioritize which rule to follow.

  1. The first rule in columns is located from top to bottom.

  2. The rule defined in type considering the precision.

  3. The general rule is defined for Data Type.

  4. The rule is defined in SnowConvert.

Example¶

Let’s say we have the following input code.

Input Code

CREATE TABLE employees (
	employee_ID NUMBER,
	manager_YEAR NUMBER(10, 0),
	manager_MONTH NUMBER(10, 0)
);
Copy

And the following renaming information

Customization File (.JSON)

{
    "types" : {
        "NUMBER" : "NUMBER(11, 2)",
        "NUMBER(10, 0)" : "NUMBER(3, 0)"    
    },
    "columns": [
        {
            "nameExpression" : "MONTH",
            "targetType" : "NUMBER(2,0)"
        }
    ]
}
Copy

This would be the output code with and without customization data types.

Snowflake output code¶
Without renaming¶
CREATE OR REPLACE TABLE employees (
	employee_ID NUMBER(38, 18) /*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/,
	manager_YEAR NUMBER(10) /*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/,
	manager_MONTH NUMBER(10) /*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/
)
;
Copy
With renaming¶
CREATE OR REPLACE TABLE employees (
	employee_ID NUMBER(11, 2),
	manager_YEAR NUMBER(3, 0),
	manager_MONTH NUMBER(2, 0)
)
;
Copy

Notice how all NUMBER types are migrated to the types specified in json file.