Drop Table
In this section, you will find information about Oracle's Drop Table statement and their Snowflake equivalent.
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.
Last updated