SQL Translation Guidelines
This article provides you with an overview of what you need to take care of when you migrate your SQL statements, Views, Functions, and Stored Procedures from Oracle to Exasol, whether you are using scripts or ETL tools to load data into your data warehouse.
General Differences
Object Names / Identifiers
Object Names / identifiers can be defined case sensitive (quoted identifiers) and case insensitive (nonquoted identifiers) in Oracle and Exasol. The difference is the characters allowed for each type. Exasol identifiers can be up to 128 characters long and can take up Oracle’s maximum potential identifier length of 128 bytes.
While in Oracle regular identifiers / nonquoted identifiers can contain alphanumeric characters, underscore (‘_’), dollar sign (‘$’) and pound sign (‘#’), even though Oracle strongly discourages using $ and # in nonquoted identifiers, Exasol supports alphanumeric characters and underscore. When a regular identifier in Oracle contains a $ or # symbol, it must be treated as a quoted identifier in Exasol.
SELECT Statement
In general, most Oracle SELECT
Statements are compatible with Exasol. The following table describes some of the most important differences.
Oracle | Exasol | Comment |
---|---|---|
|
|
Every query is executed in parallel by default. |
|
|
This example shows a simple with clause, which is the same in Oracle and Exasol. |
|
|
Both Oracle and Exasol, support the pseudo column ROWID. See ROWID for more details. |
|
|
Exasol does not support the NEXT_DAY function , but it can be easily implemented as a function using a PL/SQL-like syntax. See CREATE FUNCTION for more details. |
|
|
Exasol does not support the LAST_DAY function, but it can easily expressed using other functions. |
|
|
The return type of Oracle's |
|
|
Exasol does not support the LNNVL function, but it can easily expressed using other functions. |
|
|
Exasol does not support the PIVOT function, but this example shows how it can be expressed in Exasol anyway. |
|
|
Exasol does not support the UNPIVOT function, but this example shows how it can be expressed in Exasol anyway. |
|
|
Both, Oracle and Exasol, support analytic functions. See Analytic Functions for more details. |
|
|
NESTED JSON COLUMNS is an alternative to JSON_TABLE in Oracle. Both can be translated using the JSON_EXTRACT function in Exasol |
|
|
To see more details about JSON usage in Exasol, see JSON Path Expressions, JSON Error Handling, JSON_VALUE, and JSON_EXTRACT. Exasol does not support the JSON_EXISTS function, but it can be rewritten using the error output of the JSON_EXTRACT function as a filter condition. |
|
|
Exasol does not support filters in JSON Path Expressions. To filter on a JSON document, the filter column needs to be extracted via the JSON_EXTRACT function, using the “#” symbol for normalization. On that dataset, the filter can be applied. |
|
|
Oracle's JSON_QUERY function can be replaced by Exasol's JSON_VALUE function. The “WITH WRAPPER” option in Oracle transforms the output into an array like a varchar output. This can be achieved by applying the toarray() functions at the end of your json path expression. For more details see JSON Path Expressions. |
|
|
The JSON_TABLE function in Oracle can be used to create a relational structure on a JSON document. This can be done using the JSON_EXTRACT function in Exasol. |
DML Statements
Please note that RETURNING (used in PL/SQL) and ERROR clauses in DML statements are not supported in Exasol. The IMPORT and EXPORT statements, however, support reject limits, and the IMPORT statement can define error tables as well. Also, when executing queries via a Lua script, you can retrieve some metadata from the queries sent to the database. See Executing SQL statements through query() and pquery() for more details.
In Oracle, DMLs on very simple views can be pushed down to the base table. DMLs on views are not supported in Exasol and must be made on the base tables.
The following tables give you the most important differences in INSERT
, UPDATE
and DELETE
statements.
INSERT
The following table describes the most important differences in INSERT
statements between Oracle and Exasol:
Oracle | Exasol | Comment |
---|---|---|
|
|
A MULTI-INSERT statement is not supported in Exasol, but It can be translated into multiple simple INSERT statements. The INSERT ALL variant goes through all records to insert them into multiple tables. If conditions are defined, all conditions are checked, even if a previous condition is true. |
|
|
In this example, a conditional INSERT FIRST is used, meaning that the source record is only processed by the block, which can include multiple insert statements, where the condition becomes true first. When translating this to multiple Exasol INSERT statements, make sure to exclude all the records that were processed by a condition that was true before. |
UPDATE
The following table describes the most important differences in UPDATE
statements between Oracle and Exasol:
Oracle | Exasol | Comment |
---|---|---|
|
|
While Exasol supports subsets returning single rows in the SET clause of the UPDATE statement, it does not support correlated subqueries in the SET clause. Those subqueries can be represented using the FROM clause to define the source tables and the WHERE clause for the join and filter conditions. |
|
|
When certain requirements are met in Oracle, a query can be used to define a base dataset instead of a table. This feature is not supported in Exasol, but it can be easily rewritten using the FROM and WHERE clause of the UPDATE statement in Exasol. |
|
|
Setting value in tuples is not supported in Exasol, hence all column updates must be set separately. Correlated updates can be rewritten using the FROM and WHERE clause of the UPDATE statement in Exasol. In the FROM clause, the target table must be referenced outside a subquery. |
|
|
Alternatively, the query can be rewritten into a MERGE statement as well. Note that grouping might be necessary to ensure a stable set of rows in the source query. |
DELETE
The following table describes some important differences in DELETE
statements between Oracle and Exasol.
The FROM keyword in the DELETE
statement is optional in Oracle whereas in Exasol it is mandatory.
Oracle | Exasol | Comment |
---|---|---|
|
|
When certain requirements are met in Oracle, a SELECT query can be defined to delete rows. This is not supported in Exasol. However, it can easily be rewritten to an Exasol DELETE statement, e. g. using the EXISTS predicate. |