SnowConvert AI - Oracle - SQL Statements¶
This document details all the similarities, differences in SQL syntax and how SnowConvert AI would translate those SQL syntaxes into a functional Snowflake SQL Syntax.
Alter Table¶
This section shows you the translations related to ALTER TABLE.
Note
Some parts in the output code are omitted for clarity reasons.
1. Description¶
Use the ALTER TABLE statement to alter the definition of a nonpartitioned table, a partitioned table, a table partition, or a table subpartition. For object tables or relational tables with object columns, use ALTER TABLE to convert the table to the latest definition of its referenced type after the type has been altered (Oracle documentation).
Oracle syntax
Note
To review Snowflake syntax, review the following documentation.
2. Sample Source Patterns¶
2.1. Alter table with clauses¶
Warning
memoptimize_read_clause and memoptimize_read_clause are not applicable in Snowflake so are being removed.
Oracle¶
Snowflake¶
Note
Only some column_clauses and constraint_clauses are applicable in Snowflake. In Oracle alter table allows modifying properties from partitions created but in Snowflake, these actions are not required
2.2. Alter table with not supported cases¶
Oracle¶
Snowflake¶
2.3. ADD CONSTRAINT action¶
The ADD CONSTRAINT action has an equivalent in Snowflake, but it only one constraint can be added per ALTER TABLE statement, so it will be commented when the statement contains two or more constraints.
Warning
enable_disable_clause is removed since it is not relevant in Snowflake.
Oracle¶
Snowflake¶
Known Issues¶
Some properties on the tables may be adapted to or not applicable.
Create Database Link¶
Warning
Currently, Create Database Link statement is not being converted but it is being parsed. Also, if your source code hascreate database link statements, these are going to be accounted for in the Assessment Report.
Example of a Source Code¶
Snowflake output¶
Database Link References¶
If in your input code you use objects from the database link the output code will keep the name of these objects but the name of the database link that they are using will be removed.
Example of a Source Code¶
Snowflake output¶
Related EWIs¶
SSC-EWI-OR0123: Db Link connections not supported.
SSC-FDM-0007: Element with missing dependencies.
Drop Table¶
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
A Drop Table statement is used to remove a table. This statement varies a little between Oracle and Snowflake. Please double-check each documentation for more information regarding the differences.
In Oracle, the Drop Table syntax is:
In Snowflake, the Drop table syntax is:
The main difference is that Snowflake does not have an equal for the PURGE clause, as the table will not be permanently removed from the system. Though, the CASCADE CONSTRAINTS and the CASCADE clauses are the same. Both drop the table, even if foreign keys exist that reference this table.
Examples¶
Now, let’s see some code examples, and what it would look like after it has been transformed. Each example uses a different variation of the Drop Table statement.
Example 1:¶
This example uses the Drop Table statement as simple as possible.
Input Code:
Transformed Code:
Example 2:¶
This example uses the Drop Table statement with the PURGE clause. Remember there is no equivalent in Snowflake for the PURGE clause inside a Drop Table statement.
Input Code:
Transformed Code:
Example 3:¶
This example uses the Drop Table statement with the CASCADE CONSTRAINTS clause.
Input Code:
Transformed Code:
In the transformed code, the CONSTRAINTS word is removed from the CASCADE CONSTRAINTS clause.
Example 4:¶
This example uses the Drop Table statement with the CASCADE CONSTRAINTS and the PURGE clauses.
Input Code:
Transformed Code:
As seen, the code changes. In the new Snowflake code, the PURGE clause is removed and the CONSTRAINTS word is also removed from the CASCADE clause.
Functional Equivalence¶
Run the following code to check for functional equivalence, bear in mind the only part that is not equivalent is the PURGE clause, which in Oracle removes completely the table from the system and there is no equal for Snowflake. In both cases, the table is dropped even if it’s referenced in another table.
Oracle:
Snowflake:
Related EWIs¶
No related EWIs.
Create Index¶
Warning
Currently, Create Index statement is not being converted but it is being parsed. Also, if your source code has create index statements, these are going to be accounted for in the Assessment Report.
Example of a create index parsed code:¶
Note
Due to architectural reasons, Snowflake does not support indexes so, SnowConvert AI will remove all the code related to the creation of indexes. Snowflake automatically creates micro-partitions for every table that help speed up the performance of DML operations, the user does not have to worry about creating or managing these micro-partitions.
Usually, this is enough to have an exceptionally good query performance. However, there are ways to improve it by creating data clustering keys. Snowflake’s official page provides more information about micro-partitions and data clustering.
Create Sequence¶
Let’s first see a code example, and what it would look like after it has been transformed.
Oracle:¶
Snowflake:¶
The first change that it is done is to apply the schema or datawarehouse to the name of the sequence. The second transformation consists in removing some elements and add them as comments, since oracle has some elements in the create sequence that are not supported in Snowflake.
In Oracle, after the name of the Sequence, the elements that are NOT commented are the following
START WITH 1000
INCREMENT BY 1
If the element is not one of those, it will be commented and added as a warning just before the create sequence, like in the example.
The following elements are the ones that are removed
MAXVALUE
NOMAXVALUE
MINVALUE
NOMINVALUE
CYCLE
NOCYCLE
CACHE
NOCACHE
ORDER
NOORDER
KEEP
NOKEEP
SESSION
GLOBAL
SCALE
EXTEND
SCALE
NOEXTEND
NOSCALE
SHARD
EXTEND
SHARD
NOEXTEND
NOSHARD
SEQUENCE EXPRESSIONS¶
NEXTVAL: Snowflake grammar is the same as the Oracle one.
CURRVAL: Snowflake does not have an equivalent so it is transformed to a stub function. Check this link to understand Snowflake’s approach.
Oracle:¶
Snowflake:¶
Sequence START WITH¶
START WITH statement value may exceed the maximum value allowed by Snowflake. What Snowflake said about the start value is: Specifies the first value returned by the sequence. Supported values are any value that can be represented by a 64-bit two’s compliment integer (from -2^63 to 2^63-1). So according to the previously mentioned, the max value allowed is 9223372036854775807 for positive numbers and 9223372036854775808 for negative numbers.
Example Code¶
Oracle:¶
Snowflake:¶
Related EWIs¶
SSC-EWI-OR0069: The sequence CURRVAL property is not supported in Snowflake.
SSC-EWI-OR0068: The sequence start value exceeds the max value allowed by Snowflake.
Alter Session¶
Alter session¶
Alter session has an equivalent in Snowflake and some the variables are mapped to Snowflake variables. If a permutation of Alter Session is not supported the node will be commented and a warning will be added.
Oracle:¶
Snowflake:¶
Session Parameters Reference¶
Note
The session parameters that doesn’t appear in the table are not currently being transformed.
Session Parameter |
Snowflake transformation |
|---|---|
NLS_DATE_FORMAT |
DATE_INPUT_FORMAT and DATE_OUTPUT_FORMAT |
NLS_NUMERIC_CHARACTERS |
NOT SUPPORTED |
Known Issues¶
No issues were found.
Related EWIs¶
No related EWIs.
Create Synonym¶
Note
Some parts in the output code are omitted for clarity reasons.
Create Synonym¶
Synonyms are not supported in Snowflake. The references to the Synonyms will be changed for the original Object.
Oracle:¶
Snowflake:¶
Example 1: Synonym that refers to a table.¶
Oracle source code:
Snowflake migrated code: you’ll notice that the SELECT originally refers to a synonym, but now it refers to the table that points the synonym.
Example 2: Synonym that refers to another synonym.¶
Oracle source code:
Snowflake migrated code: you’ll notice that originally the SELECT , UPDATE, INSERT refers to a synonym, and now it refers to the atomic object, which is a table.
Example 3: Synonym that refers to a view¶
Oracle Source Code
Snowflake migrated code: you’ll notice that the SELECT originally refers to a synonym, and now it refers to the atomic objects, which is a view.
Related EWIs¶
SSC-FDM-0001: Views selecting all columns from a single table are not required in Snowflake.
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-FDM-OR0005: Synonyms are not supported in Snowflake but references to this synonym were changed by the original object name.